[llvm-branch-commits] [llvm-branch] r100430 - in /llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine: InstCombineCalls.cpp InstCombineCompares.cpp InstructionCombining.cpp

Gabor Greif ggreif at gmail.com
Mon Apr 5 08:19:58 PDT 2010


Author: ggreif
Date: Mon Apr  5 10:19:58 2010
New Revision: 100430

URL: http://llvm.org/viewvc/llvm-project?rev=100430&view=rev
Log:
more operand adjustments

Modified:
    llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstCombineCalls.cpp
    llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstCombineCompares.cpp
    llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstructionCombining.cpp

Modified: llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=100430&r1=100429&r2=100430&view=diff
==============================================================================
--- llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstCombineCalls.cpp Mon Apr  5 10:19:58 2010
@@ -390,7 +390,7 @@
     // bswap(bswap(x)) -> x
     if (IntrinsicInst *Operand = dyn_cast<IntrinsicInst>(II->getOperand(0)))
       if (Operand->getIntrinsicID() == Intrinsic::bswap)
-        return ReplaceInstUsesWith(CI, Operand->getOperand(1));
+        return ReplaceInstUsesWith(CI, Operand->getOperand(0));
       
     // bswap(trunc(bswap(x))) -> trunc(lshr(x, c))
     if (TruncInst *TI = dyn_cast<TruncInst>(II->getOperand(0))) {
@@ -399,7 +399,7 @@
           unsigned C = Operand->getType()->getPrimitiveSizeInBits() -
                        TI->getType()->getPrimitiveSizeInBits();
           Value *CV = ConstantInt::get(Operand->getType(), C);
-          Value *V = Builder->CreateLShr(Operand->getOperand(1), CV);
+          Value *V = Builder->CreateLShr(Operand->getOperand(0), CV);
           return new TruncInst(V, TI->getType());
         }
     }

Modified: llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=100430&r1=100429&r2=100430&view=diff
==============================================================================
--- llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Apr  5 10:19:58 2010
@@ -1423,7 +1423,7 @@
       switch (II->getIntrinsicID()) {
       case Intrinsic::bswap:
         Worklist.Add(II);
-        ICI.setOperand(0, II->getOperand(1));
+        ICI.setOperand(0, II->getOperand(0));
         ICI.setOperand(1, ConstantInt::get(II->getContext(), RHSV.byteSwap()));
         return &ICI;
       case Intrinsic::ctlz:
@@ -1431,7 +1431,7 @@
         // ctz(A) == bitwidth(a)  ->  A == 0 and likewise for !=
         if (RHSV == RHS->getType()->getBitWidth()) {
           Worklist.Add(II);
-          ICI.setOperand(0, II->getOperand(1));
+          ICI.setOperand(0, II->getOperand(0));
           ICI.setOperand(1, ConstantInt::get(RHS->getType(), 0));
           return &ICI;
         }
@@ -1440,7 +1440,7 @@
         // popcount(A) == 0  ->  A == 0 and likewise for !=
         if (RHS->isZero()) {
           Worklist.Add(II);
-          ICI.setOperand(0, II->getOperand(1));
+          ICI.setOperand(0, II->getOperand(0));
           ICI.setOperand(1, RHS);
           return &ICI;
         }

Modified: llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=100430&r1=100429&r2=100430&view=diff
==============================================================================
--- llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/branches/ggreif/CallInst-operands/lib/Transforms/InstCombine/InstructionCombining.cpp Mon Apr  5 10:19:58 2010
@@ -711,7 +711,7 @@
 }
 
 Instruction *InstCombiner::visitFree(Instruction &FI) {
-  Value *Op = FI.getOperand(1);
+  Value *Op = FI.getOperand(0);
 
   // free undef -> unreachable.
   if (isa<UndefValue>(Op)) {
@@ -896,7 +896,7 @@
   if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(Agg)) {
     // We're extracting from an intrinsic, see if we're the only user, which
     // allows us to simplify multiple result intrinsics to simpler things that
-    // just get one value..
+    // just get one value.
     if (II->hasOneUse()) {
       // Check if we're grabbing the overflow bit or the result of a 'with
       // overflow' intrinsic.  If it's the latter we can remove the intrinsic
@@ -905,7 +905,7 @@
       case Intrinsic::uadd_with_overflow:
       case Intrinsic::sadd_with_overflow:
         if (*EV.idx_begin() == 0) {  // Normal result.
-          Value *LHS = II->getOperand(1), *RHS = II->getOperand(2);
+          Value *LHS = II->getOperand(0), *RHS = II->getOperand(1);
           II->replaceAllUsesWith(UndefValue::get(II->getType()));
           EraseInstFromFunction(*II);
           return BinaryOperator::CreateAdd(LHS, RHS);
@@ -914,7 +914,7 @@
       case Intrinsic::usub_with_overflow:
       case Intrinsic::ssub_with_overflow:
         if (*EV.idx_begin() == 0) {  // Normal result.
-          Value *LHS = II->getOperand(1), *RHS = II->getOperand(2);
+          Value *LHS = II->getOperand(0), *RHS = II->getOperand(1);
           II->replaceAllUsesWith(UndefValue::get(II->getType()));
           EraseInstFromFunction(*II);
           return BinaryOperator::CreateSub(LHS, RHS);
@@ -923,7 +923,7 @@
       case Intrinsic::umul_with_overflow:
       case Intrinsic::smul_with_overflow:
         if (*EV.idx_begin() == 0) {  // Normal result.
-          Value *LHS = II->getOperand(1), *RHS = II->getOperand(2);
+          Value *LHS = II->getOperand(0), *RHS = II->getOperand(1);
           II->replaceAllUsesWith(UndefValue::get(II->getType()));
           EraseInstFromFunction(*II);
           return BinaryOperator::CreateMul(LHS, RHS);





More information about the llvm-branch-commits mailing list