Fold shift x, [sz]ext(y) -> shift x, y
authorNate Begeman <natebegeman@mac.com>
Tue, 12 Apr 2005 23:32:28 +0000 (23:32 +0000)
committerNate Begeman <natebegeman@mac.com>
Tue, 12 Apr 2005 23:32:28 +0000 (23:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21262 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAG.cpp

index 613d0983ad63dd39b6428a16d3f1466baccc6fca..31289464577875cd4a04d3229308155cae86a1c3 100644 (file)
@@ -911,6 +911,14 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
     if (N2.getOpcode() == ISD::FNEG)          // (A- (-B) -> A+B
       return getNode(ISD::ADD, VT, N1, N2.getOperand(0));
     break;
+  case ISD::SHL:
+  case ISD::SRL:
+  case ISD::SRA:
+    if (N2.getOpcode() == ISD::ZERO_EXTEND_INREG || 
+        N2.getOpcode() == ISD::SIGN_EXTEND_INREG) {
+      return getNode(Opcode, VT, N1, N2.getOperand(0));
+    }
+    break;
   }
 
   SDNode *&N = BinaryOps[std::make_pair(Opcode, std::make_pair(N1, N2))];
@@ -1002,6 +1010,14 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
       else
         return N1;         // Never-taken branch
     break;
+  case ISD::SRA_PARTS:
+  case ISD::SRL_PARTS:
+  case ISD::SHL_PARTS:
+    if (N3.getOpcode() == ISD::ZERO_EXTEND_INREG || 
+        N3.getOpcode() == ISD::SIGN_EXTEND_INREG) {
+      return getNode(Opcode, VT, N1, N2, N3.getOperand(0));
+    }
+    break;
   }
 
   SDNode *N = new SDNode(Opcode, N1, N2, N3);