[llvm] r344534 - [DAGCombiner] allow undef elts in vector fmul matching

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 15 09:54:08 PDT 2018


Author: spatel
Date: Mon Oct 15 09:54:07 2018
New Revision: 344534

URL: http://llvm.org/viewvc/llvm-project?rev=344534&view=rev
Log:
[DAGCombiner] allow undef elts in vector fmul matching

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    llvm/trunk/test/CodeGen/AArch64/fadd-combines.ll

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=344534&r1=344533&r2=344534&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Oct 15 09:54:07 2018
@@ -10898,7 +10898,7 @@ SDValue DAGCombiner::visitFADD(SDNode *N
   auto isFMulNegTwo = [](SDValue FMul) {
     if (!FMul.hasOneUse() || FMul.getOpcode() != ISD::FMUL)
       return false;
-    auto *C = isConstOrConstSplatFP(FMul.getOperand(1));
+    auto *C = isConstOrConstSplatFP(FMul.getOperand(1), true);
     return C && C->isExactlyValue(-2.0);
   };
 

Modified: llvm/trunk/test/CodeGen/AArch64/fadd-combines.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/fadd-combines.ll?rev=344534&r1=344533&r2=344534&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/fadd-combines.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/fadd-combines.ll Mon Oct 15 09:54:07 2018
@@ -76,9 +76,8 @@ define <4 x float> @fmulnegtwo_vec_commu
 define <4 x float> @fmulnegtwo_vec_undefs(<4 x float> %a, <4 x float> %b) {
 ; CHECK-LABEL: fmulnegtwo_vec_undefs:
 ; CHECK:       // %bb.0:
-; CHECK-NEXT:    movi v2.4s, #192, lsl #24
-; CHECK-NEXT:    fmul v1.4s, v1.4s, v2.4s
-; CHECK-NEXT:    fadd v0.4s, v0.4s, v1.4s
+; CHECK-NEXT:    fadd v1.4s, v1.4s, v1.4s
+; CHECK-NEXT:    fsub v0.4s, v0.4s, v1.4s
 ; CHECK-NEXT:    ret
   %mul = fmul <4 x float> %b, <float undef, float -2.0, float undef, float -2.0>
   %add = fadd <4 x float> %a, %mul
@@ -88,9 +87,8 @@ define <4 x float> @fmulnegtwo_vec_undef
 define <4 x float> @fmulnegtwo_vec_commute_undefs(<4 x float> %a, <4 x float> %b) {
 ; CHECK-LABEL: fmulnegtwo_vec_commute_undefs:
 ; CHECK:       // %bb.0:
-; CHECK-NEXT:    movi v2.4s, #192, lsl #24
-; CHECK-NEXT:    fmul v1.4s, v1.4s, v2.4s
-; CHECK-NEXT:    fadd v0.4s, v1.4s, v0.4s
+; CHECK-NEXT:    fadd v1.4s, v1.4s, v1.4s
+; CHECK-NEXT:    fsub v0.4s, v0.4s, v1.4s
 ; CHECK-NEXT:    ret
   %mul = fmul <4 x float> %b, <float -2.0, float undef, float -2.0, float -2.0>
   %add = fadd <4 x float> %mul, %a




More information about the llvm-commits mailing list