[PATCH] D62077: [InstSimplify] Teach fsub -0.0, (fneg X) ==> X about unary fneg
Cameron McInally via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 17 13:11:17 PDT 2019
cameron.mcinally created this revision.
cameron.mcinally added reviewers: spatel, arsenm, kpn, craig.topper, andrew.w.kaylor.
Herald added subscribers: llvm-commits, hiraditya, wdng.
Herald added a project: LLVM.
One incoming comment inline about a tough decision...
Repository:
rL LLVM
https://reviews.llvm.org/D62077
Files:
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
Index: llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
===================================================================
--- llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
+++ llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
@@ -31,9 +31,7 @@
; fsub -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 float -0.000000e+00, %t1
-; CHECK-NEXT: ret float %ret
+; CHECK-NEXT: ret float [[A:%.*]]
;
%t1 = fneg float %a
%ret = fsub float -0.0, %t1
@@ -51,9 +49,7 @@
define <2 x float> @fneg_x_vec(<2 x float> %a) {
; CHECK-LABEL: @fneg_x_vec(
-; CHECK-NEXT: %t1 = fneg <2 x float> %a
-; CHECK-NEXT: %ret = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, %t1
-; CHECK-NEXT: ret <2 x float> %ret
+; CHECK-NEXT: ret <2 x float> [[A:%.*]]
;
%t1 = fneg <2 x float> %a
%ret = fsub <2 x float> <float -0.0, float -0.0>, %t1
@@ -71,9 +67,7 @@
define <2 x float> @fneg_x_vec_undef_elts(<2 x float> %a) {
; CHECK-LABEL: @fneg_x_vec_undef_elts(
-; CHECK-NEXT: %t1 = fneg <2 x float> %a
-; CHECK-NEXT: %ret = fsub <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 <2 x float> <float -0.0, float undef>, %t1
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4394,9 +4394,10 @@
return Op0;
// fsub -0.0, (fsub -0.0, X) ==> X
+ // fsub -0.0, (fneg X) ==> X
Value *X;
if (match(Op0, m_NegZeroFP()) &&
- match(Op1, m_FSub(m_NegZeroFP(), m_Value(X))))
+ match(Op1, m_FNeg(m_Value(X))))
return X;
// fsub 0.0, (fsub 0.0, X) ==> X if signed zeros are ignored.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62077.200086.patch
Type: text/x-patch
Size: 1969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190517/73f0d037/attachment.bin>
More information about the llvm-commits
mailing list