This is an archive of the discontinued LLVM Phabricator instance.

[X86][FastISel] Fix with.overflow + select eflags clobber (PR54369)
ClosedPublic

Authored by nikic on Mar 31 2022, 8:06 AM.

Details

Summary

Don't try to directly use the with.overflow flag result in a cmov if we need to materialize constants between the instruction producing the overflow flag and the cmov. The current code is careful to check that there are no other instructions in between, but misses the constant materialization case (which may clobber eflags via xor or constant expression evaluation).

Alternatively, we could also just drop the with.overflow + select optimization.

Fixes https://github.com/llvm/llvm-project/issues/54369.

Diff Detail

Event Timeline

nikic created this revision.Mar 31 2022, 8:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 31 2022, 8:06 AM
nikic requested review of this revision.Mar 31 2022, 8:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 31 2022, 8:06 AM

I'd be open to removing the optimization entirely, anything but the simplest of folds in fast-isel seems unnecessary.

nikic added a comment.Apr 1 2022, 3:45 AM

For reference, here's how dropping the fold would like: https://gist.github.com/nikic/78da6b1abff77031bed2a948474983c6 (This only drops the with.overflow + select combination and keeps with.overflow + branch).

nikic updated this revision to Diff 421479.Apr 8 2022, 3:35 AM
nikic edited the summary of this revision. (Show Details)

Rebase over new test.

pengfei accepted this revision.Apr 8 2022, 4:08 AM

LGTM.

This revision is now accepted and ready to land.Apr 8 2022, 4:08 AM
RKSimon accepted this revision.Apr 8 2022, 4:46 AM

No objections - thanks for investigating D123014 though

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