[llvm-commits] [llvm] r94850 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
Bob Wilson
bob.wilson at apple.com
Fri Jan 29 14:39:21 PST 2010
Author: bwilson
Date: Fri Jan 29 16:39:21 2010
New Revision: 94850
URL: http://llvm.org/viewvc/llvm-project?rev=94850&view=rev
Log:
Preserve load alignment in instcombine transformations. I've been unable to
create a testcase where this matters. The select+load transformation only
occurs when isSafeToLoadUnconditionally is true, and in those situations,
instcombine also changes the underlying objects to be aligned. This seems
like a good idea regardless, and I've verified that it doesn't pessimize
the subsequent realignment.
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=94850&r1=94849&r2=94850&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp Fri Jan 29 16:39:21 2010
@@ -117,6 +117,7 @@
// the result of the loaded value.
Value *NewLoad =
IC.Builder->CreateLoad(CastOp, LI.isVolatile(), CI->getName());
+ cast<LoadInst>(NewLoad)->setAlignment(LI.getAlignment());
// Now cast the result of the load.
return new BitCastInst(NewLoad, LI.getType());
}
@@ -205,6 +206,8 @@
SI->getOperand(1)->getName()+".val");
Value *V2 = Builder->CreateLoad(SI->getOperand(2),
SI->getOperand(2)->getName()+".val");
+ cast<LoadInst>(V1)->setAlignment(LI.getAlignment());
+ cast<LoadInst>(V2)->setAlignment(LI.getAlignment());
return SelectInst::Create(SI->getCondition(), V1, V2);
}
More information about the llvm-commits
mailing list