This is an archive of the discontinued LLVM Phabricator instance.

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

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



This restores the half of:
that was reverted at:

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:

I think AArch64 and possibly other targets would benefit from enabling those hooks too. See PR30327:

And now (finally), I can abandon D24480.

Diff Detail


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.