[llvm-commits] [PATCH] Preserve load's alignment after IC xform
Cameron McInally
cameron.mcinally at nyu.edu
Wed Apr 4 11:33:35 PDT 2012
Hey guys,
I found an Instruction Combining transform that does not preserve the
alignment of the load being xformed...
Index: lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- lib/Transforms/InstCombine/InstructionCombining.cpp (revision 154024)
+++ lib/Transforms/InstCombine/InstructionCombining.cpp (working copy)
@@ -1401,7 +1401,9 @@
Value *GEP = Builder->CreateInBoundsGEP(L->getPointerOperand(),
Indices);
// Returning the load directly will cause the main loop to insert it
in
// the wrong spot, so use ReplaceInstUsesWith().
- return ReplaceInstUsesWith(EV, Builder->CreateLoad(GEP));
+ LoadInst *NewLoad = Builder->CreateLoad(GEP);
+ NewLoad->setAlignment(L->getAlignment());
+ return ReplaceInstUsesWith(EV, NewLoad);
}
// We could simplify extracts from other values. Note that nested
extracts may
// already be simplified implicitly by the above: extract (extract
(insert) )
I stumbled upon this in LLVM 2.9, but the issue still exists in trunk. It's
possible that there's a better solution to the problem in trunk, but I have
not spent time investigating.
Tx,
Cameron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120404/862a6e4d/attachment.html>
More information about the llvm-commits
mailing list