From: Benjamin Kramer Date: Sun, 14 Jun 2015 21:01:20 +0000 (+0000) Subject: [InstSimplify] fsub nnan x, x -> 0.0 is valid without ninf X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=49e5e9f0c9c44ab914897d4ed32b704e8fb35a56;p=oota-llvm.git [InstSimplify] fsub nnan x, x -> 0.0 is valid without ninf Both inf - inf and (-inf) - (-inf) are NaN, so it's already covered by nnan. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239702 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index 5e3b415a2a6..8f7a940aa95 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/lib/Analysis/InstructionSimplify.cpp @@ -854,8 +854,8 @@ static Value *SimplifyFSubInst(Value *Op0, Value *Op1, FastMathFlags FMF, return X; } - // fsub nnan ninf x, x ==> 0.0 - if (FMF.noNaNs() && FMF.noInfs() && Op0 == Op1) + // fsub nnan x, x ==> 0.0 + if (FMF.noNaNs() && Op0 == Op1) return Constant::getNullValue(Op0->getType()); return nullptr; diff --git a/test/Transforms/InstSimplify/fast-math.ll b/test/Transforms/InstSimplify/fast-math.ll index 0336301c354..c9ae7ef0f09 100644 --- a/test/Transforms/InstSimplify/fast-math.ll +++ b/test/Transforms/InstSimplify/fast-math.ll @@ -70,17 +70,17 @@ define float @fadd_fsub_0(float %a) { ret float %ret } -; fsub nnan ninf x, x ==> 0.0 +; fsub nnan x, x ==> 0.0 ; CHECK-LABEL: @fsub_x_x( define float @fsub_x_x(float %a) { ; X - X ==> 0 - %zero1 = fsub nnan ninf float %a, %a + %zero1 = fsub nnan float %a, %a ; Dont fold ; CHECK: %no_zero1 = fsub %no_zero1 = fsub ninf float %a, %a ; CHECK: %no_zero2 = fsub - %no_zero2 = fsub nnan float %a, %a + %no_zero2 = fsub float %a, %a ; CHECK: %no_zero = fadd %no_zero = fadd float %no_zero1, %no_zero2