[PATCH] D62013: [InstSimplify] Add unary fneg to `fsub 0.0, (fneg X) ==> X` transform
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 17 09:47:04 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361047: [InstSimplify] Add unary fneg to `fsub 0.0, (fneg X) ==> X` transform (authored by mcinally, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D62013?vs=199878&id=200059#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62013/new/
https://reviews.llvm.org/D62013
Files:
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/test/Transforms/InstSimplify/fast-math.ll
Index: llvm/trunk/test/Transforms/InstSimplify/fast-math.ll
===================================================================
--- llvm/trunk/test/Transforms/InstSimplify/fast-math.ll
+++ llvm/trunk/test/Transforms/InstSimplify/fast-math.ll
@@ -219,9 +219,7 @@
; fsub nsz 0.0, (fneg X) ==> X
define float @fneg_x(float %a) {
; CHECK-LABEL: @fneg_x(
-; CHECK-NEXT: [[T1:%.*]] = fneg float [[A:%.*]]
-; CHECK-NEXT: [[RET:%.*]] = fsub nsz float 0.000000e+00, [[T1]]
-; CHECK-NEXT: ret float [[RET]]
+; CHECK-NEXT: ret float [[A:%.*]]
;
%t1 = fneg float %a
%ret = fsub nsz float 0.0, %t1
@@ -239,9 +237,7 @@
define <2 x float> @fneg_x_vec_undef1(<2 x float> %a) {
; CHECK-LABEL: @fneg_x_vec_undef1(
-; CHECK-NEXT: [[T1:%.*]] = fneg <2 x float> [[A:%.*]]
-; CHECK-NEXT: [[RET:%.*]] = fsub nsz <2 x float> <float 0.000000e+00, float undef>, [[T1]]
-; CHECK-NEXT: ret <2 x float> [[RET]]
+; CHECK-NEXT: ret <2 x float> [[A:%.*]]
;
%t1 = fneg <2 x float> %a
%ret = fsub nsz <2 x float> <float 0.0, float undef>, %t1
Index: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp
@@ -4400,8 +4400,10 @@
return X;
// fsub 0.0, (fsub 0.0, X) ==> X if signed zeros are ignored.
+ // fsub 0.0, (fneg X) ==> X if signed zeros are ignored.
if (FMF.noSignedZeros() && match(Op0, m_AnyZeroFP()) &&
- match(Op1, m_FSub(m_AnyZeroFP(), m_Value(X))))
+ (match(Op1, m_FSub(m_AnyZeroFP(), m_Value(X))) ||
+ match(Op1, m_FNeg(m_Value(X)))))
return X;
// fsub nnan x, x ==> 0.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62013.200059.patch
Type: text/x-patch
Size: 1703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190517/605f62a6/attachment.bin>
More information about the llvm-commits
mailing list