This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] fix bug computing isKnownToBeAPowerOfTwo() with arithmetic shift right (PR25900)
ClosedPublic

Authored by spatel on Dec 30 2015, 11:50 AM.

Details

Summary

This is a fix for:
https://llvm.org/bugs/show_bug.cgi?id=25900

If we think that an arithmetic right shift of a power of two is always a power of two, an sdiv gets wrongly converted to udiv.
I didn't see a way to simplify the test case further.

Diff Detail

Event Timeline

spatel updated this revision to Diff 43795.Dec 30 2015, 11:50 AM
spatel retitled this revision from to [ValueTracking] fix bug computing isKnownToBeAPowerOfTwo() with arithmetic shift right (PR25900).
spatel updated this object.
spatel added reviewers: sanjoy, hfinkel, majnemer.
spatel added a subscriber: llvm-commits.
majnemer accepted this revision.Dec 30 2015, 1:03 PM
majnemer edited edge metadata.

LGTM

lib/Analysis/ValueTracking.cpp
1748–1749

I wouldn't worry about this case here. I think canonicalization should be responsible for making sure that an arithmetic shift right can be turned into a logical shift right.

This revision is now accepted and ready to land.Dec 30 2015, 1:03 PM
spatel added inline comments.Dec 30 2015, 1:54 PM
lib/Analysis/ValueTracking.cpp
1748–1749

Sounds good - I'll remove the TODO. Thanks for the prompt review!

This revision was automatically updated to reflect the committed changes.