[llvm] r344458 - [InstCombine] fix complexity canonicalization with fake unary vector ops

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 13 09:15:38 PDT 2018


Author: spatel
Date: Sat Oct 13 09:15:37 2018
New Revision: 344458

URL: http://llvm.org/viewvc/llvm-project?rev=344458&view=rev
Log:
[InstCombine] fix complexity canonicalization with fake unary vector ops

This is a preliminary step to avoid regressions when we add
an actual 'fneg' instruction to IR. See D52934 and D53205.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineInternal.h
    llvm/trunk/test/Transforms/InstCombine/operand-complexity.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineInternal.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineInternal.h?rev=344458&r1=344457&r2=344458&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineInternal.h (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineInternal.h Sat Oct 13 09:15:37 2018
@@ -82,8 +82,8 @@ class User;
 ///   5 -> Other instructions
 static inline unsigned getComplexity(Value *V) {
   if (isa<Instruction>(V)) {
-    if (isa<CastInst>(V) || BinaryOperator::isNeg(V) ||
-        BinaryOperator::isFNeg(V) || BinaryOperator::isNot(V))
+    if (isa<CastInst>(V) || match(V, m_Neg(m_Value())) ||
+        match(V, m_Not(m_Value())) || match(V, m_FNeg(m_Value())))
       return 4;
     return 5;
   }

Modified: llvm/trunk/test/Transforms/InstCombine/operand-complexity.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/operand-complexity.ll?rev=344458&r1=344457&r2=344458&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/operand-complexity.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/operand-complexity.ll Sat Oct 13 09:15:37 2018
@@ -33,7 +33,7 @@ define <2 x i8> @neg_vec_undef(<2 x i8>
 ; CHECK-LABEL: @neg_vec_undef(
 ; CHECK-NEXT:    [[BO:%.*]] = udiv <2 x i8> [[X:%.*]], <i8 42, i8 -42>
 ; CHECK-NEXT:    [[NEGX:%.*]] = sub <2 x i8> <i8 0, i8 undef>, [[X]]
-; CHECK-NEXT:    [[R:%.*]] = mul <2 x i8> [[NEGX]], [[BO]]
+; CHECK-NEXT:    [[R:%.*]] = mul <2 x i8> [[BO]], [[NEGX]]
 ; CHECK-NEXT:    ret <2 x i8> [[R]]
 ;
   %bo = udiv <2 x i8> %x, <i8 42, i8 -42>
@@ -74,7 +74,7 @@ define <2 x i8> @not_vec_undef(<2 x i8>
 ; CHECK-LABEL: @not_vec_undef(
 ; CHECK-NEXT:    [[BO:%.*]] = udiv <2 x i8> [[X:%.*]], <i8 42, i8 -42>
 ; CHECK-NEXT:    [[NOTX:%.*]] = xor <2 x i8> [[X]], <i8 -1, i8 undef>
-; CHECK-NEXT:    [[R:%.*]] = mul <2 x i8> [[NOTX]], [[BO]]
+; CHECK-NEXT:    [[R:%.*]] = mul <2 x i8> [[BO]], [[NOTX]]
 ; CHECK-NEXT:    ret <2 x i8> [[R]]
 ;
   %bo = udiv <2 x i8> %x, <i8 42, i8 -42>
@@ -123,7 +123,7 @@ define <2 x float> @fneg_vec_undef(<2 x
 ; CHECK-LABEL: @fneg_vec_undef(
 ; CHECK-NEXT:    [[BO:%.*]] = fdiv <2 x float> [[X:%.*]], <float 4.200000e+01, float -4.200000e+01>
 ; CHECK-NEXT:    [[FNEGX:%.*]] = fsub <2 x float> <float -0.000000e+00, float undef>, [[X]]
-; CHECK-NEXT:    [[R:%.*]] = fmul <2 x float> [[FNEGX]], [[BO]]
+; CHECK-NEXT:    [[R:%.*]] = fmul <2 x float> [[BO]], [[FNEGX]]
 ; CHECK-NEXT:    call void @use_vec(<2 x float> [[FNEGX]])
 ; CHECK-NEXT:    ret <2 x float> [[R]]
 ;




More information about the llvm-commits mailing list