This commit is contained in:
rwestrel 2025-06-12 17:33:14 +02:00
parent c04cefbc06
commit 2d1b109605
2 changed files with 64 additions and 40 deletions

View File

@ -3007,7 +3007,10 @@ void OuterStripMinedLoopNode::handle_sunk_stores_at_expansion(PhaseIterGVN* igvn
// Sunk stores are reachable from the memory state of the outer loop safepoint
Node* safepoint = outer_safepoint();
Node* safepoint_mem = safepoint->in(TypeFunc::Memory);
if (safepoint_mem->is_MergeMem()) {
if (!safepoint_mem->is_MergeMem()) {
assert(stores_in_outer_loop_cnt == 0, "inconsistent");
return;
}
MergeMemNode* mm = safepoint_mem->as_MergeMem();
DEBUG_ONLY(int stores_in_outer_loop_cnt2 = 0);
for (MergeMemStream mms(mm); mms.next_non_empty();) {
@ -3048,9 +3051,6 @@ void OuterStripMinedLoopNode::handle_sunk_stores_at_expansion(PhaseIterGVN* igvn
}
}
assert(stores_in_outer_loop_cnt == stores_in_outer_loop_cnt2, "inconsistent");
} else {
assert(stores_in_outer_loop_cnt == 0, "inconsistent");
}
}
void OuterStripMinedLoopNode::adjust_strip_mined_loop(PhaseIterGVN* igvn) {

View File

@ -41,6 +41,7 @@ public class TestStoresSunkInOuterStripMinedLoop {
public static void main(String[] args) {
A a1 = new A();
A a2 = new A();
A a3 = new A();
for (int i = 0; i < 20_000; i++) {
field = 0;
test1();
@ -57,6 +58,11 @@ public class TestStoresSunkInOuterStripMinedLoop {
if (a1.field != 1500) {
throw new RuntimeException(a1.field + " != 1500");
}
a1.field = 0;
test4(a1, a2, a3);
if (a1.field != 1500) {
throw new RuntimeException(a1.field + " != 1500");
}
}
}
@ -104,6 +110,24 @@ public class TestStoresSunkInOuterStripMinedLoop {
return f;
}
// Couples stores sunk in outer loop, store in inner loop
private static float test4(A a1, A a2, A a3) {
field = a1.field + a2.field + a3.field;
volatileField = 42;
int v = a1.field;
float f = 1;
A a = a2;
for (int i = 0; i < 1500; i++) {
f *= 2;
v++;
a.field = v;
a = a1;
a2.field = v;
a3.field = v;
}
return f;
}
static class A {
int field;
}