This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fix store merge worklist management
ClosedPublic

Authored by nikic on Jul 18 2020, 1:33 PM.

Details

Summary

Fixes https://bugs.llvm.org/show_bug.cgi?id=46680.

Just like insertions through IRBuilder, InsertNewInstBefore() should be using the deferred worklist mechanism, so that processing of newly added instructions is prioritized.

There's one side-effect of the worklist order change which could be classified as a regression. An add op gets pushed through a select that at the time is not a umax. We could add a reverse transform that tries to push adds in the reverse direction to restore a min/max, but that seems like a sure way of getting infinite loops :) Seems like something that should best wait on min/max intrinsics.

Diff Detail

Event Timeline

nikic created this revision.Jul 18 2020, 1:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2020, 1:33 PM
lebedev.ri added inline comments.Jul 18 2020, 1:38 PM
llvm/test/Transforms/InstCombine/pr46680.ll
2

Please precommit with larger threshold and change it here in the patch.

nikic updated this revision to Diff 279025.Jul 18 2020, 2:39 PM
nikic marked an inline comment as done.

Rebase over test.

lebedev.ri accepted this revision.Jul 18 2020, 11:12 PM

There's one side-effect of the worklist order change which could be classified as a regression. An add op gets pushed through a select that at the time is not a umax. We could add a reverse transform that tries to push adds in the reverse direction to restore a min/max, but that seems like a sure way of getting infinite loops :) Seems like something that should best wait on min/max intrinsics.

Yeah, i think we can/should easily undo that, but indeed, until intrinsics are here, it can't not cause infinite loops.

So LGTM.

This revision is now accepted and ready to land.Jul 18 2020, 11:12 PM
This revision was automatically updated to reflect the committed changes.