When folding a bitcast into a load or store, preserve the alignment

information of the original load or store, which is checked to be
at least as good, and possibly better.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52849 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2008-06-28 00:45:22 +00:00
parent fd6437f4f9
commit 77455617fb

View File

@ -3445,7 +3445,7 @@ SDOperand DAGCombiner::visitBIT_CONVERT(SDNode *N) {
if (Align <= OrigAlign) { if (Align <= OrigAlign) {
SDOperand Load = DAG.getLoad(VT, LN0->getChain(), LN0->getBasePtr(), SDOperand Load = DAG.getLoad(VT, LN0->getChain(), LN0->getBasePtr(),
LN0->getSrcValue(), LN0->getSrcValueOffset(), LN0->getSrcValue(), LN0->getSrcValueOffset(),
LN0->isVolatile(), Align); LN0->isVolatile(), OrigAlign);
AddToWorkList(N); AddToWorkList(N);
CombineTo(N0.Val, DAG.getNode(ISD::BIT_CONVERT, N0.getValueType(), Load), CombineTo(N0.Val, DAG.getNode(ISD::BIT_CONVERT, N0.getValueType(), Load),
Load.getValue(1)); Load.getValue(1));
@ -4547,7 +4547,7 @@ SDOperand DAGCombiner::visitSTORE(SDNode *N) {
((!AfterLegalize && !ST->isVolatile()) || ((!AfterLegalize && !ST->isVolatile()) ||
TLI.isOperationLegal(ISD::STORE, SVT))) TLI.isOperationLegal(ISD::STORE, SVT)))
return DAG.getStore(Chain, Value.getOperand(0), Ptr, ST->getSrcValue(), return DAG.getStore(Chain, Value.getOperand(0), Ptr, ST->getSrcValue(),
ST->getSrcValueOffset(), ST->isVolatile(), Align); ST->getSrcValueOffset(), ST->isVolatile(), OrigAlign);
} }
// Turn 'store float 1.0, Ptr' -> 'store int 0x12345678, Ptr' // Turn 'store float 1.0, Ptr' -> 'store int 0x12345678, Ptr'