forked from OSchip/llvm-project
Revert r145273 and fix in SelectionDAG::InferPtrAlignment() instead.
Conservatively returns zero when the GV does not specify an alignment nor is it initialized. Previously it returns ABI alignment for type of the GV. However, if the type is a "packed" type, then the under-specified alignments is attached to the load / store instructions. In that case, the alignment of the type cannot be trusted. rdar://10464621 llvm-svn: 145300
This commit is contained in:
parent
124d8ff0da
commit
4a5b2040e2
|
@ -6206,20 +6206,13 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) {
|
||||||
|
|
||||||
// Try to infer better alignment information than the load already has.
|
// Try to infer better alignment information than the load already has.
|
||||||
if (OptLevel != CodeGenOpt::None && LD->isUnindexed()) {
|
if (OptLevel != CodeGenOpt::None && LD->isUnindexed()) {
|
||||||
unsigned ABIAlign = TLI.getTargetData()->
|
if (unsigned Align = DAG.InferPtrAlignment(Ptr)) {
|
||||||
getABITypeAlignment(LD->getMemoryVT().getTypeForEVT(*DAG.getContext()));
|
if (Align > LD->getAlignment())
|
||||||
unsigned LDAlign = LD->getAlignment();
|
return DAG.getExtLoad(LD->getExtensionType(), N->getDebugLoc(),
|
||||||
// Do not touch loads with explicit alignments that are smaller than ABI
|
LD->getValueType(0),
|
||||||
// alignment to avoid breaking loads from "packed" types.
|
Chain, Ptr, LD->getPointerInfo(),
|
||||||
if (!LDAlign || LDAlign >= ABIAlign) {
|
LD->getMemoryVT(),
|
||||||
if (unsigned Align = DAG.InferPtrAlignment(Ptr)) {
|
LD->isVolatile(), LD->isNonTemporal(), Align);
|
||||||
if (Align > LDAlign)
|
|
||||||
return DAG.getExtLoad(LD->getExtensionType(), N->getDebugLoc(),
|
|
||||||
LD->getValueType(0),
|
|
||||||
Chain, Ptr, LD->getPointerInfo(),
|
|
||||||
LD->getMemoryVT(),
|
|
||||||
LD->isVolatile(), LD->isNonTemporal(), Align);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6676,18 +6669,11 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) {
|
||||||
|
|
||||||
// Try to infer better alignment information than the store already has.
|
// Try to infer better alignment information than the store already has.
|
||||||
if (OptLevel != CodeGenOpt::None && ST->isUnindexed()) {
|
if (OptLevel != CodeGenOpt::None && ST->isUnindexed()) {
|
||||||
unsigned ABIAlign = TLI.getTargetData()->
|
if (unsigned Align = DAG.InferPtrAlignment(Ptr)) {
|
||||||
getABITypeAlignment(ST->getMemoryVT().getTypeForEVT(*DAG.getContext()));
|
if (Align > ST->getAlignment())
|
||||||
unsigned STAlign = ST->getAlignment();
|
return DAG.getTruncStore(Chain, N->getDebugLoc(), Value,
|
||||||
// Do not touch stores with explicit alignments that are smaller than ABI
|
Ptr, ST->getPointerInfo(), ST->getMemoryVT(),
|
||||||
// alignment to avoid breaking stores from "packed" types.
|
ST->isVolatile(), ST->isNonTemporal(), Align);
|
||||||
if (!STAlign || STAlign >= ABIAlign) {
|
|
||||||
if (unsigned Align = DAG.InferPtrAlignment(Ptr)) {
|
|
||||||
if (Align > STAlign)
|
|
||||||
return DAG.getTruncStore(Chain, N->getDebugLoc(), Value,
|
|
||||||
Ptr, ST->getPointerInfo(), ST->getMemoryVT(),
|
|
||||||
ST->isVolatile(), ST->isNonTemporal(),Align);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6564,7 +6564,11 @@ unsigned SelectionDAG::InferPtrAlignment(SDValue Ptr) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Align)
|
if (!Align)
|
||||||
Align = TLI.getTargetData()->getABITypeAlignment(GV->getType());
|
// Conservatively returns zero here instead of using ABI alignment for
|
||||||
|
// type of the GV. If the type is a "packed" type, then the under-
|
||||||
|
// specified alignments is attached to the load / store instructions.
|
||||||
|
// In that case, the alignment of the type cannot be trusted.
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return MinAlign(Align, GVOffset);
|
return MinAlign(Align, GVOffset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ define void @reset(<2 x float>* noalias %garbage1) {
|
||||||
store i32 0, i32* %changed, align 4
|
store i32 0, i32* %changed, align 4
|
||||||
%r2 = getelementptr float* bitcast ([20 x i64]* @compl to float*), i64 32 ; <float*> [#uses=1]
|
%r2 = getelementptr float* bitcast ([20 x i64]* @compl to float*), i64 32 ; <float*> [#uses=1]
|
||||||
%r3 = bitcast float* %r2 to <2 x float>* ; <<2 x float>*> [#uses=1]
|
%r3 = bitcast float* %r2 to <2 x float>* ; <<2 x float>*> [#uses=1]
|
||||||
%r4 = load <2 x float>* %r3, align 8 ; <<2 x float>> [#uses=1]
|
%r4 = load <2 x float>* %r3, align 4 ; <<2 x float>> [#uses=1]
|
||||||
call void @killcommon(i32* %changed)
|
call void @killcommon(i32* %changed)
|
||||||
br label %"file complex.c, line 34, bb4"
|
br label %"file complex.c, line 34, bb4"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue