Fix this xform: (sra (shl X, m), result_size) -> (sign_extend (trunc (shl X, result_size - n - m)))

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48578 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng
2008-03-20 02:18:41 +00:00
parent 71a2cb25eb
commit 260e07ec8c
3 changed files with 19 additions and 3 deletions

View File

@@ -2400,7 +2400,9 @@ SDOperand DAGCombiner::visitSRA(SDNode *N) {
// If the shift wouldn't be a noop, the truncated type is an actual type,
// and the truncate is free, then proceed with the transform.
if (ShiftAmt != 0 && TLI.isTruncateFree(VT, TruncVT)) {
if (ShiftAmt != 0 &&
TLI.isTypeLegal(TruncVT) &&
TLI.isTruncateFree(VT, TruncVT)) {
SDOperand Amt = DAG.getConstant(ShiftAmt, TLI.getShiftAmountTy());
SDOperand Shift = DAG.getNode(ISD::SRL, VT, N0.getOperand(0), Amt);
SDOperand Trunc = DAG.getNode(ISD::TRUNCATE, TruncVT, Shift);