From: Sanjay Patel Date: Thu, 12 Mar 2020 13:52:06 +0000 (-0400) Subject: [InstSimplify] simplify FP ops harder with FMF (part 2) X-Git-Tag: llvmorg-12-init~12300 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a66dc755db4cd0af678b0dd7a84ca64fd66518f6;p=platform%2Fupstream%2Fllvm.git [InstSimplify] simplify FP ops harder with FMF (part 2) This is part of the IR sibling for: D75576 Related transform committed with: rG8ec71585719d --- diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 6144618..de73106 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -4611,11 +4611,11 @@ static Constant *simplifyFPOp(ArrayRef Ops, bool IsUndef = match(V, m_Undef()); // If this operation has 'nnan' or 'ninf' and at least 1 disallowed operand - // (TODO: an undef operand can be chosen to be Nan/Inf), then the result of + // (an undef operand can be chosen to be Nan/Inf), then the result of // this operation is poison. That result can be relaxed to undef. - if (FMF.noNaNs() && IsNan) + if (FMF.noNaNs() && (IsNan || IsUndef)) return UndefValue::get(V->getType()); - if (FMF.noInfs() && IsInf) + if (FMF.noInfs() && (IsInf || IsUndef)) return UndefValue::get(V->getType()); if (IsUndef || IsNan) diff --git a/llvm/test/Transforms/InstSimplify/fp-undef.ll b/llvm/test/Transforms/InstSimplify/fp-undef.ll index cdf887f..7b11955 100644 --- a/llvm/test/Transforms/InstSimplify/fp-undef.ll +++ b/llvm/test/Transforms/InstSimplify/fp-undef.ll @@ -85,7 +85,7 @@ define float @frem_undef_op1(float %x) { define float @fadd_undef_op0_nnan(float %x) { ; CHECK-LABEL: @fadd_undef_op0_nnan( -; CHECK-NEXT: ret float 0x7FF8000000000000 +; CHECK-NEXT: ret float undef ; %r = fadd nnan float undef, %x ret float %r @@ -93,7 +93,7 @@ define float @fadd_undef_op0_nnan(float %x) { define float @fadd_undef_op1_fast(float %x) { ; CHECK-LABEL: @fadd_undef_op1_fast( -; CHECK-NEXT: ret float 0x7FF8000000000000 +; CHECK-NEXT: ret float undef ; %r = fadd fast float %x, undef ret float %r @@ -101,7 +101,7 @@ define float @fadd_undef_op1_fast(float %x) { define float @fsub_undef_op0_fast(float %x) { ; CHECK-LABEL: @fsub_undef_op0_fast( -; CHECK-NEXT: ret float 0x7FF8000000000000 +; CHECK-NEXT: ret float undef ; %r = fsub fast float undef, %x ret float %r @@ -109,7 +109,7 @@ define float @fsub_undef_op0_fast(float %x) { define float @fsub_undef_op1_nnan(float %x) { ; CHECK-LABEL: @fsub_undef_op1_nnan( -; CHECK-NEXT: ret float 0x7FF8000000000000 +; CHECK-NEXT: ret float undef ; %r = fsub nnan float %x, undef ret float %r @@ -117,7 +117,7 @@ define float @fsub_undef_op1_nnan(float %x) { define float @fmul_undef_op0_nnan(float %x) { ; CHECK-LABEL: @fmul_undef_op0_nnan( -; CHECK-NEXT: ret float 0x7FF8000000000000 +; CHECK-NEXT: ret float undef ; %r = fmul nnan float undef, %x ret float %r @@ -125,7 +125,7 @@ define float @fmul_undef_op0_nnan(float %x) { define float @fmul_undef_op1_fast(float %x) { ; CHECK-LABEL: @fmul_undef_op1_fast( -; CHECK-NEXT: ret float 0x7FF8000000000000 +; CHECK-NEXT: ret float undef ; %r = fmul fast float %x, undef ret float %r @@ -133,7 +133,7 @@ define float @fmul_undef_op1_fast(float %x) { define float @fdiv_undef_op0_fast(float %x) { ; CHECK-LABEL: @fdiv_undef_op0_fast( -; CHECK-NEXT: ret float 0x7FF8000000000000 +; CHECK-NEXT: ret float undef ; %r = fdiv fast float undef, %x ret float %r @@ -141,7 +141,7 @@ define float @fdiv_undef_op0_fast(float %x) { define float @fdiv_undef_op1_nnan(float %x) { ; CHECK-LABEL: @fdiv_undef_op1_nnan( -; CHECK-NEXT: ret float 0x7FF8000000000000 +; CHECK-NEXT: ret float undef ; %r = fdiv nnan float %x, undef ret float %r @@ -149,7 +149,7 @@ define float @fdiv_undef_op1_nnan(float %x) { define float @frem_undef_op0_nnan(float %x) { ; CHECK-LABEL: @frem_undef_op0_nnan( -; CHECK-NEXT: ret float 0x7FF8000000000000 +; CHECK-NEXT: ret float undef ; %r = frem nnan float undef, %x ret float %r @@ -157,7 +157,7 @@ define float @frem_undef_op0_nnan(float %x) { define float @frem_undef_op1_fast(float %x) { ; CHECK-LABEL: @frem_undef_op1_fast( -; CHECK-NEXT: ret float 0x7FF8000000000000 +; CHECK-NEXT: ret float undef ; %r = frem fast float %x, undef ret float %r