mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-27 06:54:30 +00:00
[InlineCost] Skip volatile loads when looking for repeated loads
This is a follow-up fix of r320814. A test case is also added. llvm-svn: 321075
This commit is contained in:
parent
804c89f41f
commit
354d0a92b6
@ -363,6 +363,7 @@ void CallAnalyzer::accumulateSROACost(DenseMap<Value *, int>::iterator CostIt,
|
|||||||
void CallAnalyzer::disableLoadElimination() {
|
void CallAnalyzer::disableLoadElimination() {
|
||||||
if (EnableLoadElimination) {
|
if (EnableLoadElimination) {
|
||||||
Cost += LoadEliminationCost;
|
Cost += LoadEliminationCost;
|
||||||
|
LoadEliminationCost = 0;
|
||||||
EnableLoadElimination = false;
|
EnableLoadElimination = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1097,7 +1098,7 @@ bool CallAnalyzer::visitLoad(LoadInst &I) {
|
|||||||
// by any stores or calls, this load is likely to be redundant and can be
|
// by any stores or calls, this load is likely to be redundant and can be
|
||||||
// eliminated.
|
// eliminated.
|
||||||
if (EnableLoadElimination &&
|
if (EnableLoadElimination &&
|
||||||
!LoadAddrSet.insert(I.getPointerOperand()).second) {
|
!LoadAddrSet.insert(I.getPointerOperand()).second && I.isUnordered()) {
|
||||||
LoadEliminationCost += InlineConstants::InstrCost;
|
LoadEliminationCost += InlineConstants::InstrCost;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -184,3 +184,21 @@ define void @inner9(i32* %a, void ()* %f) {
|
|||||||
call void @pad()
|
call void @pad()
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
define void @outer10(i32* %a) {
|
||||||
|
; CHECK-LABEL: @outer10(
|
||||||
|
; CHECK: call void @inner10
|
||||||
|
%b = alloca i32
|
||||||
|
call void @inner10(i32* %a, i32* %b)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @inner10(i32* %a, i32* %b) {
|
||||||
|
%1 = load i32, i32* %a
|
||||||
|
store i32 %1, i32 * %b
|
||||||
|
%2 = load volatile i32, i32* %a ; volatile load should be kept.
|
||||||
|
call void @pad()
|
||||||
|
%3 = load volatile i32, i32* %a ; Same as the above.
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user