[llvm-commits] [llvm] r94863 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

Bob Wilson bob.wilson at apple.com
Fri Jan 29 16:41:10 PST 2010


Author: bwilson
Date: Fri Jan 29 18:41:10 2010
New Revision: 94863

URL: http://llvm.org/viewvc/llvm-project?rev=94863&view=rev
Log:
Use more specific types to avoid casts.  No functionality change.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp?rev=94863&r1=94862&r2=94863&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp Fri Jan 29 18:41:10 2010
@@ -115,9 +115,9 @@
         // Okay, we are casting from one integer or pointer type to another of
         // the same size.  Instead of casting the pointer before the load, cast
         // the result of the loaded value.
-        Value *NewLoad = 
+        LoadInst *NewLoad = 
           IC.Builder->CreateLoad(CastOp, LI.isVolatile(), CI->getName());
-        cast<LoadInst>(NewLoad)->setAlignment(LI.getAlignment());
+        NewLoad->setAlignment(LI.getAlignment());
         // Now cast the result of the load.
         return new BitCastInst(NewLoad, LI.getType());
       }
@@ -202,12 +202,12 @@
       // load (select (Cond, &V1, &V2))  --> select(Cond, load &V1, load &V2).
       if (isSafeToLoadUnconditionally(SI->getOperand(1), SI, TD) &&
           isSafeToLoadUnconditionally(SI->getOperand(2), SI, TD)) {
-        Value *V1 = Builder->CreateLoad(SI->getOperand(1),
+        LoadInst *V1 = Builder->CreateLoad(SI->getOperand(1),
                                         SI->getOperand(1)->getName()+".val");
-        Value *V2 = Builder->CreateLoad(SI->getOperand(2),
+        LoadInst *V2 = Builder->CreateLoad(SI->getOperand(2),
                                         SI->getOperand(2)->getName()+".val");
-        cast<LoadInst>(V1)->setAlignment(LI.getAlignment());
-        cast<LoadInst>(V2)->setAlignment(LI.getAlignment());
+        V1->setAlignment(LI.getAlignment());
+        V2->setAlignment(LI.getAlignment());
         return SelectInst::Create(SI->getCondition(), V1, V2);
       }
 





More information about the llvm-commits mailing list