[llvm] r332407 - [InstCombine] fix binop (shuffle X), C --> shuffle (binop X, C') to check uses

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue May 15 15:00:37 PDT 2018


Author: spatel
Date: Tue May 15 15:00:37 2018
New Revision: 332407

URL: http://llvm.org/viewvc/llvm-project?rev=332407&view=rev
Log:
[InstCombine] fix binop (shuffle X), C --> shuffle (binop X, C') to check uses

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
    llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=332407&r1=332406&r2=332407&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Tue May 15 15:00:37 2018
@@ -1395,7 +1395,7 @@ Value *InstCombiner::SimplifyVectorOp(Bi
   // transforms.
   Constant *C;
   if (match(&Inst, m_c_BinOp(
-          m_ShuffleVector(m_Value(V1), m_Undef(), m_Constant(Mask)),
+          m_OneUse(m_ShuffleVector(m_Value(V1), m_Undef(), m_Constant(Mask))),
           m_Constant(C))) &&
       V1->getType() == Inst.getType()) {
     // Find constant NewC that has property:

Modified: llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll?rev=332407&r1=332406&r2=332407&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll Tue May 15 15:00:37 2018
@@ -420,15 +420,14 @@ define <4 x i32> @sub_const(<4 x i32> %v
   ret <4 x i32> %r
 }
 
-; FIXME: Math before shuffle requires an extra shuffle.
+; Math before shuffle requires an extra shuffle.
 
 define <2 x float> @fadd_const_multiuse(<2 x float> %v) {
 ; CHECK-LABEL: @fadd_const_multiuse(
 ; CHECK-NEXT:    [[T1:%.*]] = shufflevector <2 x float> [[V:%.*]], <2 x float> undef, <2 x i32> <i32 1, i32 0>
-; CHECK-NEXT:    [[TMP1:%.*]] = fadd <2 x float> [[V]], <float 4.200000e+01, float 4.100000e+01>
-; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <2 x float> [[TMP1]], <2 x float> undef, <2 x i32> <i32 1, i32 0>
+; CHECK-NEXT:    [[R:%.*]] = fadd <2 x float> [[T1]], <float 4.100000e+01, float 4.200000e+01>
 ; CHECK-NEXT:    call void @use(<2 x float> [[T1]])
-; CHECK-NEXT:    ret <2 x float> [[TMP2]]
+; CHECK-NEXT:    ret <2 x float> [[R]]
 ;
   %t1 = shufflevector <2 x float> %v, <2 x float> undef, <2 x i32> <i32 1, i32 0>
   %r = fadd <2 x float> %t1, <float 41.0, float 42.0>




More information about the llvm-commits mailing list