Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8527,6 +8527,9 @@ static Instruction *foldFCmpFSubIntoFCmp(FCmpInst &I, Instruction *LHSI,
DenormalMode::getIEEE()) {
CI.replaceOperand(I, 0, X);
CI.replaceOperand(I, 1, Y);
I.setHasNoInfs(LHSI->hasNoInfs());
if (LHSI->hasNoNaNs())
I.setHasNoNaNs(true);
return &I;
}
break;
Expand Down
40 changes: 40 additions & 0 deletions llvm/test/Transforms/InstCombine/fcmp.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1812,6 +1812,46 @@ define i1 @fcmp_ule_fsub_const(float %x, float %y) {
ret i1 %cmp
}

define i1 @fcmp_ninf_ule_fsub_const(float %x, float %y) {
; CHECK-LABEL: @fcmp_ninf_ule_fsub_const(
; CHECK-NEXT: [[CMP:%.*]] = fcmp ule float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%fs = fsub float %x, %y
%cmp = fcmp ninf ule float %fs, 0.000000e+00
ret i1 %cmp
}

define i1 @fcmp_nnan_ule_fsub_const(float %x, float %y) {
; CHECK-LABEL: @fcmp_nnan_ule_fsub_const(
; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan ule float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%fs = fsub float %x, %y
%cmp = fcmp nnan ule float %fs, 0.000000e+00
ret i1 %cmp
}

define i1 @fcmp_ule_fsub_ninf_const(float %x, float %y) {
; CHECK-LABEL: @fcmp_ule_fsub_ninf_const(
; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ule float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%fs = fsub ninf float %x, %y
%cmp = fcmp ule float %fs, 0.000000e+00
ret i1 %cmp
}

define i1 @fcmp_ule_fsub_nnan_const(float %x, float %y) {
; CHECK-LABEL: @fcmp_ule_fsub_nnan_const(
; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan ule float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%fs = fsub nnan float %x, %y
%cmp = fcmp ule float %fs, 0.000000e+00
ret i1 %cmp
}

define i1 @fcmp_ugt_fsub_const(float %x, float %y) {
; CHECK-LABEL: @fcmp_ugt_fsub_const(
; CHECK-NEXT: [[FS:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
Expand Down
Loading