Page MenuHomePhabricator

[InstCombine] Inefficient pattern for high-bits checking 3 (PR38708)
ClosedPublic

Authored by lebedev.ri on Sep 13 2018, 2:43 PM.

Details

Summary

It is sometimes important to check that some newly-computed value
is non-negative and only n bits wide (where n is a variable.)
There are many ways to check that:
https://godbolt.org/z/o4RB8D
The last variant seems best?
(I'm sure there are some other variations i haven't thought of..)

The last (as far i know?) pattern, non-canonical due to the extra use.
https://godbolt.org/z/aCMsPk
https://rise4fun.com/Alive/I6f

https://bugs.llvm.org/show_bug.cgi?id=38708

Diff Detail

Repository
rL LLVM

Event Timeline

spatel accepted this revision.Sep 14 2018, 9:34 AM

LGTM - might want to add a code comment that we're only expecting this pattern in the multi-use case otherwise, it would have been canonicalized to the 'not' form.

This revision is now accepted and ready to land.Sep 14 2018, 9:34 AM

LGTM

Thank you for the review!

might want to add a code comment that we're only expecting this pattern in the multi-use case otherwise, it would have been canonicalized to the 'not' form.

Yeah, good idea.

This revision was automatically updated to reflect the committed changes.