(i32 sext_in_reg (i32 aext (i16 x)), i16) -> (i32 sext x). No known test case until...
authorEvan Cheng <evan.cheng@apple.com>
Fri, 16 Apr 2010 22:26:19 +0000 (22:26 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Fri, 16 Apr 2010 22:26:19 +0000 (22:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101551 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index 5c53a7f6bd17dbca0ab3f6e0c3c508da785b120b..9ba9bb5e38d0dac4cde7e98930b99de4872c96ad 100644 (file)
@@ -3748,7 +3748,8 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
   // if x is small enough.
   if (N0.getOpcode() == ISD::SIGN_EXTEND || N0.getOpcode() == ISD::ANY_EXTEND) {
     SDValue N00 = N0.getOperand(0);
-    if (N00.getValueType().getScalarType().getSizeInBits() < EVTBits)
+    if (N00.getValueType().getScalarType().getSizeInBits() <= EVTBits &&
+        (!LegalOperations || TLI.isOperationLegal(ISD::SIGN_EXTEND, VT)))
       return DAG.getNode(ISD::SIGN_EXTEND, N->getDebugLoc(), VT, N00, N1);
   }