[llvm] r239702 - [InstSimplify] fsub nnan x, x -> 0.0 is valid without ninf
Benjamin Kramer
benny.kra at googlemail.com
Sun Jun 14 14:01:21 PDT 2015
Author: d0k
Date: Sun Jun 14 16:01:20 2015
New Revision: 239702
URL: http://llvm.org/viewvc/llvm-project?rev=239702&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/test/Transforms/InstSimplify/fast-math.ll
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=239702&r1=239701&r2=239702&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Sun Jun 14 16:01:20 2015
@@ -854,8 +854,8 @@ static Value *SimplifyFSubInst(Value *Op
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;
Modified: llvm/trunk/test/Transforms/InstSimplify/fast-math.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/fast-math.ll?rev=239702&r1=239701&r2=239702&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/fast-math.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/fast-math.ll Sun Jun 14 16:01:20 2015
@@ -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
More information about the llvm-commits
mailing list