Add constant replacement for insertelement/vectorshuffle constant exprs
authorChris Lattner <sabre@nondot.org>
Sat, 8 Apr 2006 05:09:48 +0000 (05:09 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 8 Apr 2006 05:09:48 +0000 (05:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27532 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Constants.cpp

index 9f706b9bc1bd1e102246e477eba713c32ece6067..22a14fb14efaacc0bdd836b5c5ad5cca791f5530 100644 (file)
@@ -1702,6 +1702,22 @@ void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV,
     if (C1 == From) C1 = To;
     if (C2 == From) C2 = To;
     Replacement = ConstantExpr::getExtractElement(C1, C2);
+  } else if (getOpcode() == Instruction::InsertElement) {
+    Constant *C1 = getOperand(0);
+    Constant *C2 = getOperand(1);
+    Constant *C3 = getOperand(1);
+    if (C1 == From) C1 = To;
+    if (C2 == From) C2 = To;
+    if (C3 == From) C3 = To;
+    Replacement = ConstantExpr::getInsertElement(C1, C2, C3);
+  } else if (getOpcode() == Instruction::ShuffleVector) {
+    Constant *C1 = getOperand(0);
+    Constant *C2 = getOperand(1);
+    Constant *C3 = getOperand(2);
+    if (C1 == From) C1 = To;
+    if (C2 == From) C2 = To;
+    if (C3 == From) C3 = To;
+    Replacement = ConstantExpr::getShuffleVector(C1, C2, C3);
   } else if (getNumOperands() == 2) {
     Constant *C1 = getOperand(0);
     Constant *C2 = getOperand(1);