Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 1 deletion llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,8 @@ Instruction *InstCombinerImpl::FoldOpIntoSelect(Instruction &Op, SelectInst *SI,
if (auto *CI = dyn_cast<FCmpInst>(SI->getCondition())) {
if (CI->hasOneUse()) {
Value *Op0 = CI->getOperand(0), *Op1 = CI->getOperand(1);
if ((TV == Op0 && FV == Op1) || (FV == Op0 && TV == Op1))
if (((TV == Op0 && FV == Op1) || (FV == Op0 && TV == Op1)) &&
!CI->isCommutative())
return nullptr;
}
}
Expand Down
11 changes: 11 additions & 0 deletions llvm/test/Transforms/InstCombine/fcmp-select.ll
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,14 @@ define i1 @test_fcmp_select_var_const_unordered(double %x, double %y) {
%cmp2 = fcmp ugt double %sel, 0x3E80000000000000
ret i1 %cmp2
}

define i1 @test_fcmp_ord_select_fcmp_oeq_var_const(double %x) {
; CHECK-LABEL: @test_fcmp_ord_select_fcmp_oeq_var_const(
; CHECK-NEXT: [[CMP1:%.*]] = fcmp oeq double [[X:%.*]], 0.000000e+00
; CHECK-NEXT: ret i1 [[CMP1]]
;
%cmp1 = fcmp ord double %x, 0.000000e+00
%sel = select i1 %cmp1, double %x, double 0.000000e+00
%cmp2 = fcmp oeq double %sel, 1.000000e+00
ret i1 %cmp2
}
Loading