Added support for decomposing constant expressions containing shr and shl
authorJohn Criswell <criswell@uiuc.edu>
Wed, 11 May 2005 21:16:42 +0000 (21:16 +0000)
committerJohn Criswell <criswell@uiuc.edu>
Wed, 11 May 2005 21:16:42 +0000 (21:16 +0000)
instructions.
Review of this commit would be greatly appreciated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21876 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/SparcV9/SparcV9PreSelection.cpp

index 7e801243ae3c27948357fe9e3061c80835306677..a13019e20613143b568713c483973a8a169d8cf7 100644 (file)
@@ -146,6 +146,30 @@ static Instruction* DecomposeConstantExpr(ConstantExpr* CE,
       return new SelectInst (C, S1, S2, "constantSelect", &insertBefore);
     }
 
+    case Instruction::Shr: {
+      getArg1 = CE->getOperand(0);
+      if (ConstantExpr* CEarg = dyn_cast<ConstantExpr>(getArg1))
+        getArg1 = DecomposeConstantExpr(CEarg, insertBefore);
+      getArg2 = CE->getOperand(1);
+      if (ConstantExpr* CEarg = dyn_cast<ConstantExpr>(getArg2))
+        getArg2 = DecomposeConstantExpr(CEarg, insertBefore);
+      return new ShiftInst (static_cast<Instruction::OtherOps>(CE->getOpcode()),
+                            getArg1, getArg2,
+                            "constantShr:" + getArg1->getName(), &insertBefore);
+    }
+
+    case Instruction::Shl: {
+      getArg1 = CE->getOperand(0);
+      if (ConstantExpr* CEarg = dyn_cast<ConstantExpr>(getArg1))
+        getArg1 = DecomposeConstantExpr(CEarg, insertBefore);
+      getArg2 = CE->getOperand(1);
+      if (ConstantExpr* CEarg = dyn_cast<ConstantExpr>(getArg2))
+        getArg2 = DecomposeConstantExpr(CEarg, insertBefore);
+      return new ShiftInst (static_cast<Instruction::OtherOps>(CE->getOpcode()),
+                            getArg1, getArg2,
+                            "constantShl:" + getArg1->getName(), &insertBefore);
+    }
+
     default:                            // must be a binary operator
       assert(CE->getOpcode() >= Instruction::BinaryOpsBegin &&
              CE->getOpcode() <  Instruction::BinaryOpsEnd &&