From e208d8fad23f01d36cc0ce7bd5f7c61c3c39774d Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Thu, 12 Mar 2020 09:52:06 -0400 Subject: [PATCH] [InstSimplify] simplify FP ops harder with FMF (part 2) This is part of the IR sibling for: D75576 Related transform committed with: rG8ec71585719d --- lib/Analysis/InstructionSimplify.cpp | 6 +++--- test/Transforms/InstSimplify/fp-undef.ll | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index 6144618003d..de7310623e8 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/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/test/Transforms/InstSimplify/fp-undef.ll b/test/Transforms/InstSimplify/fp-undef.ll index cdf887f3363..7b11955d9b3 100644 --- a/test/Transforms/InstSimplify/fp-undef.ll +++ b/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