1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes=early-cse -earlycse-debug-hash | FileCheck %s
3 ; RUN: opt < %s -S -passes='early-cse<memssa>' | FileCheck %s
5 define i64 @branching_int(i32 %a) {
6 ; CHECK-LABEL: @branching_int(
7 ; CHECK-NEXT: [[CONV1:%.*]] = zext i32 [[A:%.*]] to i64
8 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i64 1, [[CONV1]]
9 ; CHECK-NEXT: br i1 [[CMP2]], label [[IF_THEN3:%.*]], label [[IF_END3:%.*]]
11 ; CHECK-NEXT: [[C:%.*]] = call double @truefunc.f64.i1(i1 true)
12 ; CHECK-NEXT: br label [[OUT:%.*]]
14 ; CHECK-NEXT: [[D:%.*]] = call double @falsefunc.f64.i1(i1 false)
15 ; CHECK-NEXT: br label [[OUT]]
17 ; CHECK-NEXT: ret i64 [[CONV1]]
19 %conv1 = zext i32 %a to i64
20 %cmp2 = icmp ugt i64 1, %conv1
21 br i1 %cmp2, label %if.then3, label %if.end3
24 %c = call double @truefunc.f64.i1(i1 %cmp2)
28 %d = call double @falsefunc.f64.i1(i1 %cmp2)
35 define double @branching_fp(i64 %a) {
36 ; CHECK-LABEL: @branching_fp(
37 ; CHECK-NEXT: [[CONV1:%.*]] = uitofp i64 [[A:%.*]] to double
38 ; CHECK-NEXT: [[CMP2:%.*]] = fcmp ogt double 1.000000e+00, [[CONV1]]
39 ; CHECK-NEXT: br i1 [[CMP2]], label [[IF_THEN3:%.*]], label [[IF_END3:%.*]]
41 ; CHECK-NEXT: [[C:%.*]] = call double @truefunc.f64.i1(i1 true)
42 ; CHECK-NEXT: br label [[OUT:%.*]]
44 ; CHECK-NEXT: [[D:%.*]] = call double @falsefunc.f64.i1(i1 false)
45 ; CHECK-NEXT: br label [[OUT]]
47 ; CHECK-NEXT: ret double [[CONV1]]
49 %conv1 = uitofp i64 %a to double
50 %cmp2 = fcmp ogt double 1.000000e+00, %conv1
51 br i1 %cmp2, label %if.then3, label %if.end3
54 %c = call double @truefunc.f64.i1(i1 %cmp2)
58 %d = call double @falsefunc.f64.i1(i1 %cmp2)
65 define double @branching_exceptignore(i64 %a) #0 {
66 ; CHECK-LABEL: @branching_exceptignore(
67 ; CHECK-NEXT: [[CONV1:%.*]] = call double @llvm.experimental.constrained.uitofp.f64.i64(i64 [[A:%.*]], metadata !"round.tonearest", metadata !"fpexcept.ignore") #[[ATTR0:[0-9]+]]
68 ; CHECK-NEXT: [[CMP2:%.*]] = call i1 @llvm.experimental.constrained.fcmps.f64(double 1.000000e+00, double [[CONV1]], metadata !"ogt", metadata !"fpexcept.ignore") #[[ATTR0]]
69 ; CHECK-NEXT: br i1 [[CMP2]], label [[IF_THEN3:%.*]], label [[IF_END3:%.*]]
71 ; CHECK-NEXT: [[C:%.*]] = call double @truefunc.f64.i1(i1 true) #[[ATTR0]]
72 ; CHECK-NEXT: br label [[OUT:%.*]]
74 ; CHECK-NEXT: [[D:%.*]] = call double @falsefunc.f64.i1(i1 false) #[[ATTR0]]
75 ; CHECK-NEXT: br label [[OUT]]
77 ; CHECK-NEXT: ret double [[CONV1]]
79 %conv1 = call double @llvm.experimental.constrained.uitofp.f64.i64(i64 %a, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
80 %cmp2 = call i1 @llvm.experimental.constrained.fcmps.f64(double 1.000000e+00, double %conv1, metadata !"ogt", metadata !"fpexcept.ignore") #0
81 br i1 %cmp2, label %if.then3, label %if.end3
84 %c = call double @truefunc.f64.i1(i1 %cmp2) #0
88 %d = call double @falsefunc.f64.i1(i1 %cmp2) #0
95 define double @branching_exceptignore_dynround(i64 %a) #0 {
96 ; CHECK-LABEL: @branching_exceptignore_dynround(
97 ; CHECK-NEXT: [[CONV1:%.*]] = call double @llvm.experimental.constrained.uitofp.f64.i64(i64 [[A:%.*]], metadata !"round.dynamic", metadata !"fpexcept.ignore") #[[ATTR0]]
98 ; CHECK-NEXT: [[CMP2:%.*]] = call i1 @llvm.experimental.constrained.fcmps.f64(double 1.000000e+00, double [[CONV1]], metadata !"ogt", metadata !"fpexcept.ignore") #[[ATTR0]]
99 ; CHECK-NEXT: br i1 [[CMP2]], label [[IF_THEN3:%.*]], label [[IF_END3:%.*]]
101 ; CHECK-NEXT: [[C:%.*]] = call double @truefunc.f64.i1(i1 true) #[[ATTR0]]
102 ; CHECK-NEXT: br label [[OUT:%.*]]
104 ; CHECK-NEXT: [[D:%.*]] = call double @falsefunc.f64.i1(i1 false) #[[ATTR0]]
105 ; CHECK-NEXT: br label [[OUT]]
107 ; CHECK-NEXT: ret double [[CONV1]]
109 %conv1 = call double @llvm.experimental.constrained.uitofp.f64.i64(i64 %a, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
110 %cmp2 = call i1 @llvm.experimental.constrained.fcmps.f64(double 1.000000e+00, double %conv1, metadata !"ogt", metadata !"fpexcept.ignore") #0
111 br i1 %cmp2, label %if.then3, label %if.end3
114 %c = call double @truefunc.f64.i1(i1 %cmp2) #0
118 %d = call double @falsefunc.f64.i1(i1 %cmp2) #0
125 define double @branching_maytrap(i64 %a) #0 {
126 ; CHECK-LABEL: @branching_maytrap(
127 ; CHECK-NEXT: [[CONV1:%.*]] = call double @llvm.experimental.constrained.uitofp.f64.i64(i64 [[A:%.*]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]]
128 ; CHECK-NEXT: [[CMP2:%.*]] = call i1 @llvm.experimental.constrained.fcmps.f64(double 1.000000e+00, double [[CONV1]], metadata !"ogt", metadata !"fpexcept.maytrap") #[[ATTR0]]
129 ; CHECK-NEXT: br i1 [[CMP2]], label [[IF_THEN3:%.*]], label [[IF_END3:%.*]]
131 ; CHECK-NEXT: [[C:%.*]] = call double @truefunc.f64.i1(i1 true) #[[ATTR0]]
132 ; CHECK-NEXT: br label [[OUT:%.*]]
134 ; CHECK-NEXT: [[D:%.*]] = call double @falsefunc.f64.i1(i1 false) #[[ATTR0]]
135 ; CHECK-NEXT: br label [[OUT]]
137 ; CHECK-NEXT: ret double [[CONV1]]
139 %conv1 = call double @llvm.experimental.constrained.uitofp.f64.i64(i64 %a, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0
140 %cmp2 = call i1 @llvm.experimental.constrained.fcmps.f64(double 1.000000e+00, double %conv1, metadata !"ogt", metadata !"fpexcept.maytrap") #0
141 br i1 %cmp2, label %if.then3, label %if.end3
144 %c = call double @truefunc.f64.i1(i1 %cmp2) #0
148 %d = call double @falsefunc.f64.i1(i1 %cmp2) #0
155 ; TODO: Fix this optimization so it works with strict exception behavior.
156 ; TODO: This may or may not be worth the added complication and risk.
157 define double @branching_ebstrict(i64 %a) #0 {
158 ; CHECK-LABEL: @branching_ebstrict(
159 ; CHECK-NEXT: [[CONV1:%.*]] = call double @llvm.experimental.constrained.uitofp.f64.i64(i64 [[A:%.*]], metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]]
160 ; CHECK-NEXT: [[CMP2:%.*]] = call i1 @llvm.experimental.constrained.fcmps.f64(double 1.000000e+00, double [[CONV1]], metadata !"ogt", metadata !"fpexcept.strict") #[[ATTR0]]
161 ; CHECK-NEXT: br i1 [[CMP2]], label [[IF_THEN3:%.*]], label [[IF_END3:%.*]]
163 ; CHECK-NEXT: [[C:%.*]] = call double @truefunc.f64.i1(i1 [[CMP2]]) #[[ATTR0]]
164 ; CHECK-NEXT: br label [[OUT:%.*]]
166 ; CHECK-NEXT: [[D:%.*]] = call double @falsefunc.f64.i1(i1 [[CMP2]]) #[[ATTR0]]
167 ; CHECK-NEXT: br label [[OUT]]
169 ; CHECK-NEXT: ret double [[CONV1]]
171 %conv1 = call double @llvm.experimental.constrained.uitofp.f64.i64(i64 %a, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
172 %cmp2 = call i1 @llvm.experimental.constrained.fcmps.f64(double 1.000000e+00, double %conv1, metadata !"ogt", metadata !"fpexcept.strict") #0
173 br i1 %cmp2, label %if.then3, label %if.end3
176 %c = call double @truefunc.f64.i1(i1 %cmp2) #0
180 %d = call double @falsefunc.f64.i1(i1 %cmp2) #0
187 declare double @truefunc.f64.i1(i1)
188 declare double @falsefunc.f64.i1(i1)
189 declare double @llvm.experimental.constrained.uitofp.f64.i64(i64, metadata, metadata) #0
190 declare i1 @llvm.experimental.constrained.fcmps.f64(double, double, metadata, metadata) #0
192 attributes #0 = { strictfp }
194 declare <4 x float> @llvm.experimental.constrained.fadd.v4f32(<4 x float>, <4 x float>, metadata, metadata) strictfp