blob: dd117c9652f84d558a3528ced940542b3e0c88e8 [file] [log] [blame]
Tobias Grosserf4ee3712015-10-06 15:36:44 +00001; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
Johannes Doerfertda803862014-06-18 23:08:14 +00002;
3; CHECK: Function: f_no_fast_math
Johannes Doerfertf6183392014-07-01 20:52:51 +00004; CHECK: Reduction Type: NONE
Johannes Doerfertda803862014-06-18 23:08:14 +00005; CHECK: Function: f_fast_math
Johannes Doerfert32868bf2014-08-01 08:13:25 +00006; CHECK: Reduction Type: +
Johannes Doerfertda803862014-06-18 23:08:14 +00007;
8; void f(float *sum) {
9; for (int i = 0; i < 100; i++)
10; *sum += 3.41 * i;
11; }
12target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
13
14define void @f_no_fast_math(float* %sum) {
15entry:
16 br label %for.cond
17
18for.cond: ; preds = %for.inc, %entry
19 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
20 %exitcond = icmp ne i32 %i.0, 100
21 br i1 %exitcond, label %for.body, label %for.end
22
23for.body: ; preds = %for.cond
24 %conv = sitofp i32 %i.0 to float
25 %pi = fptrunc double 3.41 to float
26 %mul = fmul float %conv, %pi
David Blaikiec94eca02015-02-27 21:22:50 +000027 %tmp = load float, float* %sum, align 4
Johannes Doerfertda803862014-06-18 23:08:14 +000028 %add = fadd float %tmp, %mul
29 store float %add, float* %sum, align 4
30 br label %for.inc
31
32for.inc: ; preds = %for.body
33 %inc = add nsw i32 %i.0, 1
34 br label %for.cond
35
36for.end: ; preds = %for.cond
37 ret void
38}
39
40define void @f_fast_math(float* %sum) {
41entry:
42 br label %for.cond
43
44for.cond: ; preds = %for.inc, %entry
45 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
46 %exitcond = icmp ne i32 %i.0, 100
47 br i1 %exitcond, label %for.body, label %for.end
48
49for.body: ; preds = %for.cond
50 %conv = sitofp i32 %i.0 to float
51 %pi = fptrunc double 3.41 to float
52 %mul = fmul fast float %conv, %pi
David Blaikiec94eca02015-02-27 21:22:50 +000053 %tmp = load float, float* %sum, align 4
Johannes Doerfertda803862014-06-18 23:08:14 +000054 %add = fadd fast float %tmp, %mul
55 store float %add, float* %sum, align 4
56 br label %for.inc
57
58for.inc: ; preds = %for.body
59 %inc = add nsw i32 %i.0, 1
60 br label %for.cond
61
62for.end: ; preds = %for.cond
63 ret void
64}