Closed Bug 1009304 Opened 10 years ago Closed 10 years ago

Redundant instructions after LICM

Categories

(Core :: JavaScript Engine: JIT, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 831773

People

(Reporter: sunfish, Unassigned)

Details

Attachments

(1 file)

LICM can hoist congruent values out of loops from places inside the loop where none of them are dominating each other (so GVN can't eliminate them) all into the preheader where they are all together.

For example, in this code:

  for (...) {
     if (x) {
        ... = a + b;
     }
     if (y) {
        ... = a + b;
     }
  }

GVN can't eliminate either copy of "a + b" because neither dominates the other. But if LICM hoists them:

        ... = a + b;
        ... = a + b;
  for (...) {
     if (x) {
     }
     if (y) {
     }
  }

Now they could be easily eliminated.

The attached experiment patch just re-runs GVN (and UCE) after LICM. It eliminates about 4% of the final number of instructions in sqlite3 VdbeExec. It doesn't appear to have a significant performance impact in that benchmark though, probably because most of the redundant instructions are outside of the loop by that time.

Another possible approach is to have LICM keep track of redundant values as it hoists.
I don't see a performance change on the benchmark suite either. But the code savings here *have* to help in some cases. Perhaps it would matter more on ARM?
I've also seen this on (non-Emscripten) benchmarks, would be nice to have this fixed.

Maybe LICM could have an heuristic to decide whether it's worth re-running GVN? Ideally we'd run the new, faster GVN implementation you're working on :)
Indeed. Thanks!
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: