Skip to content

Commit

Permalink
[DAGCombine] Don't check the legality of type when combine the SIGN_E…
Browse files Browse the repository at this point in the history
…XTEND_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
  • Loading branch information
QingShan Zhang committed Jan 6, 2020
1 parent 2c05310 commit b9780f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Expand Up @@ -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));
}
Expand Down
5 changes: 1 addition & 4 deletions llvm/test/CodeGen/PowerPC/sext-vector-inreg.ll
Expand Up @@ -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:
Expand Down

0 comments on commit b9780f4

Please sign in to comment.