File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
lib/Transforms/InstCombine
test/Transforms/InstCombine Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -7972,6 +7972,11 @@ Instruction *InstCombinerImpl::visitFCmpInst(FCmpInst &I) {
7972
7972
Constant *RHSC;
7973
7973
if (match (Op0, m_Instruction (LHSI)) && match (Op1, m_Constant (RHSC))) {
7974
7974
switch (LHSI->getOpcode ()) {
7975
+ case Instruction::FSub:
7976
+ if (Pred == FCmpInst::FCMP_OGT && match (RHSC, m_PosZeroFP ()) &&
7977
+ match (LHSI, m_OneUse (m_FSub (m_Value (X), m_Value (Y)))))
7978
+ return new FCmpInst (Pred, X, Y);
7979
+ break ;
7975
7980
case Instruction::PHI:
7976
7981
if (Instruction *NV = foldOpIntoPhi (I, cast<PHINode>(LHSI)))
7977
7982
return NV;
Original file line number Diff line number Diff line change @@ -1284,3 +1284,26 @@ define <1 x i1> @bitcast_1vec_eq0(i32 %x) {
1284
1284
%cmp = fcmp oeq <1 x float > %f , zeroinitializer
1285
1285
ret <1 x i1 > %cmp
1286
1286
}
1287
+
1288
+ define i1 @fcmp_fsub_const (float %x , float %y ) {
1289
+ ; CHECK-LABEL: @fcmp_fsub_const(
1290
+ ; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt float [[X:%.*]], [[Y:%.*]]
1291
+ ; CHECK-NEXT: ret i1 [[CMP]]
1292
+ ;
1293
+ %fs = fsub float %x , %y
1294
+ %cmp = fcmp ogt float %fs , 0 .000000e+00
1295
+ ret i1 %cmp
1296
+ }
1297
+
1298
+ define i1 @fcmp_fsub_const_extra (float %x , float %y ) {
1299
+ ; CHECK-LABEL: @fcmp_fsub_const_extra(
1300
+ ; CHECK-NEXT: [[FS:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
1301
+ ; CHECK-NEXT: call void @use(float [[FS]])
1302
+ ; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt float [[FS]], 0.000000e+00
1303
+ ; CHECK-NEXT: ret i1 [[CMP]]
1304
+ ;
1305
+ %fs = fsub float %x , %y
1306
+ call void @use (float %fs )
1307
+ %cmp = fcmp ogt float %fs , 0 .000000e+00
1308
+ ret i1 %cmp
1309
+ }
You can’t perform that action at this time.
0 commit comments