[llvm] b9780f4 - [DAGCombine] Don't check the legality of type when combine the SIGN_EXTEND_INREG

QingShan Zhang via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 5 19:04:41 PST 2020


Author: QingShan Zhang
Date: 2020-01-06T03:00:58Z
New Revision: b9780f4f80ba82c6271b6b87fbfe6ea32d154e49

URL: https://github.com/llvm/llvm-project/commit/b9780f4f80ba82c6271b6b87fbfe6ea32d154e49
DIFF: https://github.com/llvm/llvm-project/commit/b9780f4f80ba82c6271b6b87fbfe6ea32d154e49.diff

LOG: [DAGCombine] Don't check the legality of type when combine the SIGN_EXTEND_INREG

This is the DAG node for SIGN_EXTEND_INREG :

t21: v4i32 = sign_extend_inreg t18, ValueType:ch:v4i16

It has two operands. The first one is the value it want to extend, and the second
one is the type to specify how to extend the value. For this example, it means
that, it is signed extend the t18(v4i32) from v4i16 to v4i32. That is
the semantics of c code:

vector int foo(vector int m) {
   return m << 16 >> 16;
}

And it could be any vector type that hardware support the operation, though
the type 'v4i16' is NOT legal for the target. When we are trying to combine
the srl + sra, what we did now is calling the TLI.isOperationLegal(), which
will also check the legality of the type. That doesn't make sense.

Differential Revision: https://reviews.llvm.org/D70230

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    llvm/test/CodeGen/PowerPC/sext-vector-inreg.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index d401e7fb657b..611ea782aa74 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -7733,8 +7733,9 @@ SDValue DAGCombiner::visitSRA(SDNode *N) {
     if (VT.isVector())
       ExtVT = EVT::getVectorVT(*DAG.getContext(),
                                ExtVT, VT.getVectorNumElements());
-    if ((!LegalOperations ||
-         TLI.isOperationLegal(ISD::SIGN_EXTEND_INREG, ExtVT)))
+    if (!LegalOperations ||
+        TLI.getOperationAction(ISD::SIGN_EXTEND_INREG, ExtVT) ==
+        TargetLowering::Legal)
       return DAG.getNode(ISD::SIGN_EXTEND_INREG, SDLoc(N), VT,
                          N0.getOperand(0), DAG.getValueType(ExtVT));
   }

diff  --git a/llvm/test/CodeGen/PowerPC/sext-vector-inreg.ll b/llvm/test/CodeGen/PowerPC/sext-vector-inreg.ll
index 8dce954d9d18..11d4d15293d4 100644
--- a/llvm/test/CodeGen/PowerPC/sext-vector-inreg.ll
+++ b/llvm/test/CodeGen/PowerPC/sext-vector-inreg.ll
@@ -4,11 +4,8 @@
 define <4 x i32> @test_signext_vector_inreg(<4 x i16> %n) {
 ; CHECK-P9-LABEL: test_signext_vector_inreg:
 ; CHECK-P9:       # %bb.0: # %entry
-; CHECK-P9-NEXT:    vspltisw 3, 8
 ; CHECK-P9-NEXT:    vmrglh 2, 2, 2
-; CHECK-P9-NEXT:    vadduwm 3, 3, 3
-; CHECK-P9-NEXT:    vslw 2, 2, 3
-; CHECK-P9-NEXT:    vsraw 2, 2, 3
+; CHECK-P9-NEXT:    vextsh2w 2, 2
 ; CHECK-P9-NEXT:    blr
 ;
 ; CHECK-P8-LABEL: test_signext_vector_inreg:


        


More information about the llvm-commits mailing list