This is an archive of the discontinued LLVM Phabricator instance.

[X86] Use XOR for SUB (C, X) during isel if will help fold an immediate
ClosedPublic

Authored by craig.topper on Jun 25 2018, 12:25 PM.

Details

Summary

Same idea as D48529, but restricted to X86 and done very late to avoid any surprises where subtract might be better for DAG combining.

This seems like the safest way to do this trick. And we consider doing it as a DAG combine later.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Jun 25 2018, 12:25 PM

I agree with the direction. It's hard to generalize folds for select-of-constants even for x86 alone because there are so many weird cases.

I've made patches that do something like these:
https://rise4fun.com/Alive/Mwl

...but unraveling all of the regressions is painful.

test/CodeGen/X86/extract-lowbits.ll
31 ↗(On Diff #152746)

This shouldn't be in the patch?

Remove the extra test change.

spatel accepted this revision.Jun 25 2018, 2:12 PM

LGTM.

This revision is now accepted and ready to land.Jun 25 2018, 2:12 PM
This revision was automatically updated to reflect the committed changes.