This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] canonicalize constant-minus-boolean to select-of-constants
ClosedPublic

Authored by spatel on Nov 29 2017, 10:03 AM.

Details

Summary

This restores the half of:
https://reviews.llvm.org/rL75531
that was reverted at:
https://reviews.llvm.org/rL159230

For the x86 case mentioned there, we now produce:
leal 1(%rdi), %eax
subl %esi, %eax

We have target hooks to invert this in DAGCombiner (and x86 is enabled) with:
https://reviews.llvm.org/rL296977
https://reviews.llvm.org/rL311731

I think AArch64 and possibly other targets would benefit from enabling those hooks too. See PR30327:
https://bugs.llvm.org/show_bug.cgi?id=30327#c2

And now (finally), I can abandon D24480.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel created this revision.Nov 29 2017, 10:03 AM
efriedma accepted this revision.Dec 6 2017, 11:57 AM

LGTM. We clearly should be canonicalizing expressions like this, and DAGCombine can reverse the transform if necessary.

This revision is now accepted and ready to land.Dec 6 2017, 11:57 AM
This revision was automatically updated to reflect the committed changes.