--- a/src/hotspot/share/opto/superword.cpp Thu Apr 26 12:39:15 2018 -0700
+++ b/src/hotspot/share/opto/superword.cpp Thu Apr 26 12:48:35 2018 -0700
@@ -2144,8 +2144,21 @@
// we use the memory state of the last load. However, if any load could
// not be moved down due to the dependence constraint, we use the memory
// state of the first load.
- Node* last_mem = executed_last(pk)->in(MemNode::Memory);
- Node* first_mem = executed_first(pk)->in(MemNode::Memory);
+ Node* first_mem = pk->at(0)->in(MemNode::Memory);
+ Node* last_mem = first_mem;
+ for (uint i = 1; i < pk->size(); i++) {
+ Node* ld = pk->at(i);
+ Node* mem = ld->in(MemNode::Memory);
+ assert(in_bb(first_mem) || in_bb(mem) || mem == first_mem, "2 different memory state from outside the loop?");
+ if (in_bb(mem)) {
+ if (in_bb(first_mem) && bb_idx(mem) < bb_idx(first_mem)) {
+ first_mem = mem;
+ }
+ if (!in_bb(last_mem) || bb_idx(mem) > bb_idx(last_mem)) {
+ last_mem = mem;
+ }
+ }
+ }
bool schedule_last = true;
for (uint i = 0; i < pk->size(); i++) {
Node* ld = pk->at(i);