This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Combine `(x + y) - y -> x` and friends
ClosedPublic

Authored by paquette on Sep 30 2022, 9:55 PM.

Details

Summary

This adds a combine that handles

(x + y) - y -> x
(x + y) - x -> y
x - (y + x) -> 0 - y
x - (x + z) -> 0 - z

On AArch64, we get added benefit for 0 - y because it can be selected to a neg instruction.

Diff Detail

Event Timeline

paquette created this revision.Sep 30 2022, 9:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 30 2022, 9:55 PM
paquette requested review of this revision.Sep 30 2022, 9:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 30 2022, 9:55 PM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm added inline comments.Oct 1 2022, 12:51 PM
llvm/test/CodeGen/AArch64/GlobalISel/combine-add-of-sub.mir
275

Should also add vector cases

paquette updated this revision to Diff 464517.Oct 1 2022, 1:30 PM

add vector stuff

arsenm accepted this revision.Oct 1 2022, 1:55 PM
This revision is now accepted and ready to land.Oct 1 2022, 1:55 PM
This revision was landed with ongoing or failed builds.Oct 3 2022, 10:16 AM
This revision was automatically updated to reflect the committed changes.