Revert X + X --> X * 2 optz'n which pessimizes heavily on x86.
authorNick Lewycky <nicholas@mxc.ca>
Fri, 23 May 2008 04:34:58 +0000 (04:34 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Fri, 23 May 2008 04:34:58 +0000 (04:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51474 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp
test/Transforms/InstCombine/2008-05-22-FoldAddIVec.ll [deleted file]

index 1a8786810561787727bc7e7fd4f2a9f202f6b9e9..655ca4b0a660e287975474c856ae6c03cdfa87e4 100644 (file)
@@ -2292,22 +2292,14 @@ static Instruction *AssociativeOpt(BinaryOperator &Root, const Functor &F) {
 
 namespace {
 
-// AddRHS - Implements: X + X --> X << 1 and X + X --> X * 2 for vectors
+// AddRHS - Implements: X + X --> X << 1
 struct AddRHS {
   Value *RHS;
   AddRHS(Value *rhs) : RHS(rhs) {}
   bool shouldApply(Value *LHS) const { return LHS == RHS; }
   Instruction *apply(BinaryOperator &Add) const {
-    if (Add.getType()->getTypeID() == Type::VectorTyID) {
-      const VectorType *VTy = cast<VectorType>(Add.getType());
-      ConstantInt *CI = ConstantInt::get(VTy->getElementType(), 2);
-      std::vector<Constant*> Elts(VTy->getNumElements(), CI);
-      return BinaryOperator::CreateMul(Add.getOperand(0),
-                                       ConstantVector::get(Elts));
-    } else {
-      return BinaryOperator::CreateShl(Add.getOperand(0),
-                                       ConstantInt::get(Add.getType(), 1));
-    }
+    return BinaryOperator::CreateShl(Add.getOperand(0),
+                                     ConstantInt::get(Add.getType(), 1));
   }
 };
 
@@ -2635,8 +2627,8 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
     }
   }
 
-  // X + X --> X << 1 and X + X --> X * 2 for vectors
-  if (I.getType()->isIntOrIntVector() && I.getType() != Type::Int1Ty) {
+  // X + X --> X
+  if (I.getType()->isInteger() && I.getType() != Type::Int1Ty) {
     if (Instruction *Result = AssociativeOpt(I, AddRHS(RHS))) return Result;
 
     if (Instruction *RHSI = dyn_cast<Instruction>(RHS)) {
diff --git a/test/Transforms/InstCombine/2008-05-22-FoldAddIVec.ll b/test/Transforms/InstCombine/2008-05-22-FoldAddIVec.ll
deleted file mode 100644 (file)
index 8bdf9bb..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep mul
-
-define <3 x i8> @f(<3 x i8> %i) {
-  %A = add <3 x i8> %i, %i
-  ret <3 x i8> %A
-}