Skip to content

Commit ba95bd5

Browse files
committed
[InstCombine] Fix FMF propagation in foldFCmpFSubIntoFCmp
1 parent fe70756 commit ba95bd5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8527,6 +8527,9 @@ static Instruction *foldFCmpFSubIntoFCmp(FCmpInst &I, Instruction *LHSI,
85278527
DenormalMode::getIEEE()) {
85288528
CI.replaceOperand(I, 0, X);
85298529
CI.replaceOperand(I, 1, Y);
8530+
I.setHasNoInfs(LHSI->hasNoInfs());
8531+
if (LHSI->hasNoNaNs())
8532+
I.setHasNoNaNs(true);
85308533
return &I;
85318534
}
85328535
break;

llvm/test/Transforms/InstCombine/fcmp.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,7 @@ define i1 @fcmp_ule_fsub_const(float %x, float %y) {
18141814

18151815
define i1 @fcmp_ninf_ule_fsub_const(float %x, float %y) {
18161816
; CHECK-LABEL: @fcmp_ninf_ule_fsub_const(
1817-
; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ule float [[X:%.*]], [[Y:%.*]]
1817+
; CHECK-NEXT: [[CMP:%.*]] = fcmp ule float [[X:%.*]], [[Y:%.*]]
18181818
; CHECK-NEXT: ret i1 [[CMP]]
18191819
;
18201820
%fs = fsub float %x, %y
@@ -1834,7 +1834,7 @@ define i1 @fcmp_nnan_ule_fsub_const(float %x, float %y) {
18341834

18351835
define i1 @fcmp_ule_fsub_ninf_const(float %x, float %y) {
18361836
; CHECK-LABEL: @fcmp_ule_fsub_ninf_const(
1837-
; CHECK-NEXT: [[CMP:%.*]] = fcmp ule float [[X:%.*]], [[Y:%.*]]
1837+
; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ule float [[X:%.*]], [[Y:%.*]]
18381838
; CHECK-NEXT: ret i1 [[CMP]]
18391839
;
18401840
%fs = fsub ninf float %x, %y
@@ -1844,7 +1844,7 @@ define i1 @fcmp_ule_fsub_ninf_const(float %x, float %y) {
18441844

18451845
define i1 @fcmp_ule_fsub_nnan_const(float %x, float %y) {
18461846
; CHECK-LABEL: @fcmp_ule_fsub_nnan_const(
1847-
; CHECK-NEXT: [[CMP:%.*]] = fcmp ule float [[X:%.*]], [[Y:%.*]]
1847+
; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan ule float [[X:%.*]], [[Y:%.*]]
18481848
; CHECK-NEXT: ret i1 [[CMP]]
18491849
;
18501850
%fs = fsub nnan float %x, %y

0 commit comments

Comments
 (0)