<div>Hey guys,</div><div><br></div><div>I found an Instruction Combining transform that does not preserve the alignment of the load being xformed...</div><div><br></div><div>Index: lib/Transforms/InstCombine/InstructionCombining.cpp</div>
<div>===================================================================</div><div>--- lib/Transforms/InstCombine/InstructionCombining.cpp<span class="Apple-tab-span" style="white-space:pre">     </span>(revision 154024)</div>
<div>+++ lib/Transforms/InstCombine/InstructionCombining.cpp<span class="Apple-tab-span" style="white-space:pre">       </span>(working copy)</div><div>@@ -1401,7 +1401,9 @@</div><div>       Value *GEP = Builder->CreateInBoundsGEP(L->getPointerOperand(), Indices);</div>
<div>       // Returning the load directly will cause the main loop to insert it in</div><div>       // the wrong spot, so use ReplaceInstUsesWith().</div><div>-      return ReplaceInstUsesWith(EV, Builder->CreateLoad(GEP));</div>
<div>+      LoadInst *NewLoad = Builder->CreateLoad(GEP);</div><div>+      NewLoad->setAlignment(L->getAlignment());</div><div>+      return ReplaceInstUsesWith(EV, NewLoad);</div><div>     }</div><div>   // We could simplify extracts from other values. Note that nested extracts may</div>
<div>   // already be simplified implicitly by the above: extract (extract (insert) )</div><div><br></div><div><br></div><div>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.</div>
<div><br></div><div>Tx,</div><div>Cameron</div>