[llvm] r321075 - [InlineCost] Skip volatile loads when looking for repeated loads
Haicheng Wu via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 19 05:42:58 PST 2017
Author: haicheng
Date: Tue Dec 19 05:42:58 2017
New Revision: 321075
URL: http://llvm.org/viewvc/llvm-project?rev=321075&view=rev
Log:
[InlineCost] Skip volatile loads when looking for repeated loads
This is a follow-up fix of r320814. A test case is also added.
Modified:
llvm/trunk/lib/Analysis/InlineCost.cpp
llvm/trunk/test/Transforms/Inline/redundant-loads.ll
Modified: llvm/trunk/lib/Analysis/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=321075&r1=321074&r2=321075&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InlineCost.cpp (original)
+++ llvm/trunk/lib/Analysis/InlineCost.cpp Tue Dec 19 05:42:58 2017
@@ -363,6 +363,7 @@ void CallAnalyzer::accumulateSROACost(De
void CallAnalyzer::disableLoadElimination() {
if (EnableLoadElimination) {
Cost += LoadEliminationCost;
+ LoadEliminationCost = 0;
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
// eliminated.
if (EnableLoadElimination &&
- !LoadAddrSet.insert(I.getPointerOperand()).second) {
+ !LoadAddrSet.insert(I.getPointerOperand()).second && I.isUnordered()) {
LoadEliminationCost += InlineConstants::InstrCost;
return true;
}
Modified: llvm/trunk/test/Transforms/Inline/redundant-loads.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/redundant-loads.ll?rev=321075&r1=321074&r2=321075&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Inline/redundant-loads.ll (original)
+++ llvm/trunk/test/Transforms/Inline/redundant-loads.ll Tue Dec 19 05:42:58 2017
@@ -184,3 +184,21 @@ define void @inner9(i32* %a, void ()* %f
call void @pad()
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
+}
More information about the llvm-commits
mailing list