This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] recognize more variants of smin/smax
ClosedPublic

Authored by spatel on Oct 28 2016, 10:59 AM.

Details

Summary

Try harder to detect obfuscated min/max patterns: the initial pattern was added with D9352 / rL236202. There was a bug fix for PR27137 at rL264996, but I think we can do better by folding the corresponding smax pattern and commuted variants.

For the PR27137 test case, we could further transform that to a mask with the smeared sign bit (ashr/and/not), but I'm not sure if we want to do that in IR?

Diff Detail

Repository
rL LLVM

Event Timeline

spatel updated this revision to Diff 76216.Oct 28 2016, 10:59 AM
spatel retitled this revision from to [ValueTracking] recognize more variants of smin/smax.
spatel updated this object.
spatel added reviewers: sanjoy, efriedma, majnemer.
spatel added a subscriber: llvm-commits.
efriedma accepted this revision.Oct 28 2016, 4:41 PM
efriedma edited edge metadata.

Code changes look fine.

test/Transforms/InstCombine/max-of-nots.ll
143 ↗(On Diff #76216)

Is there really no better way to write a testcase for this? I guess there are a limited number of transforms which use min/max formation, but this seems awkward.

This revision is now accepted and ready to land.Oct 28 2016, 4:41 PM
spatel added inline comments.Oct 29 2016, 8:45 AM
test/Transforms/InstCombine/max-of-nots.ll
143 ↗(On Diff #76216)

Agree - I thought it was best to add to the existing IR test, and I assumed there wasn't a better instcombine way to expose this.

However, as shown in the related D26096, we can see the difference in vector codegen with the minimal IR patterns. Let me add similar tests here. I still think it's best if we keep these instcombine tests for bonus coverage though, but let me know if you think that's overkill.

Thanks for the prompt review!

This revision was automatically updated to reflect the committed changes.