1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[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.

llvm-svn: 239702
This commit is contained in:
Benjamin Kramer 2015-06-14 21:01:20 +00:00
parent fea304711c
commit ea33a66cc1
2 changed files with 5 additions and 5 deletions

View File

@ -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;

View File

@ -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