This is an archive of the discontinued LLVM Phabricator instance.

[X86] selectLEAAddr - relax heuristic to only require one operand to be a MathWithFlags op (PR46809)
ClosedPublic

Authored by RKSimon on Jan 25 2022, 4:53 AM.

Details

Summary

As suggested by @craig.topper, relaxing LEA matching to only require the ADD to be fed from a single op with EFLAGS helps avoid duplication when the EFLAGS are consumed in a later, dependent instruction.

There was some concern about whether the heuristic is too simple, not taking into account lost loads that can't fold by using a LEA, but some basic tests (included in select-lea.ll) don't suggest that's really a problem. I'm open to suggestions on other tests we could try?

Diff Detail

Event Timeline

RKSimon created this revision.Jan 25 2022, 4:53 AM
RKSimon requested review of this revision.Jan 25 2022, 4:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2022, 4:53 AM
RKSimon edited the summary of this revision. (Show Details)Jan 26 2022, 3:07 AM

ping - any thoughts?

spatel accepted this revision.Feb 8 2022, 6:27 AM

LGTM. The check was intentionally conservative to begin, and the diffs all seem like improvements.

This revision is now accepted and ready to land.Feb 8 2022, 6:27 AM
spatel added a comment.Feb 8 2022, 6:32 AM

For reference -- and in case you're looking for even more LEAs :) -- the other TODO items were mentioned in the original review:
D64707

This revision was landed with ongoing or failed builds.Feb 8 2022, 7:09 AM
This revision was automatically updated to reflect the committed changes.