Skip to content

Commit 29c97ce

Browse files
dtcxzywsivan-shani
authored andcommitted
[InstCombine] Use canIgnoreSignBitOfZero in spf->minmax fold (llvm#141914)
Alive2: https://alive2.llvm.org/ce/z/dCZBB_ Fix remaining regressions caused by llvm#141010.
1 parent 8371720 commit 29c97ce

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3929,7 +3929,10 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
39293929

39303930
// Canonicalize select of FP values where NaN and -0.0 are not valid as
39313931
// minnum/maxnum intrinsics.
3932-
if (SIFPOp->hasNoNaNs() && SIFPOp->hasNoSignedZeros()) {
3932+
if (SIFPOp->hasNoNaNs() &&
3933+
(SIFPOp->hasNoSignedZeros() ||
3934+
(SIFPOp->hasOneUse() &&
3935+
canIgnoreSignBitOfZero(*SIFPOp->use_begin())))) {
39333936
Value *X, *Y;
39343937
if (match(&SI, m_OrdOrUnordFMax(m_Value(X), m_Value(Y)))) {
39353938
Value *BinIntr =

llvm/test/Transforms/InstCombine/minmax-fp.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ define i8 @t11(float %a, float %b) {
174174
; Either operand could be NaN, but nnan modifier applied.
175175
define i8 @t12(float %a, float %b) {
176176
; CHECK-LABEL: @t12(
177-
; CHECK-NEXT: [[DOTINV:%.*]] = fcmp nnan oge float [[B:%.*]], [[A:%.*]]
178-
; CHECK-NEXT: [[DOTV:%.*]] = select nnan i1 [[DOTINV]], float [[A]], float [[B]]
177+
; CHECK-NEXT: [[DOTV:%.*]] = call nnan float @llvm.minnum.f32(float [[B:%.*]], float [[A:%.*]])
179178
; CHECK-NEXT: [[TMP1:%.*]] = fptosi float [[DOTV]] to i8
180179
; CHECK-NEXT: ret i8 [[TMP1]]
181180
;

0 commit comments

Comments
 (0)