This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking, InstCombine] extend isKnownToBeAPowerOfTwo() to handle vector splat constants
ClosedPublic

Authored by spatel on May 20 2016, 3:34 PM.

Details

Summary

We could try harder and handle non-splat vector constants too, but that seems much rarer to me.
Note that the div test isn't resolved because there's a check for isIntegerTy() guarding that transform.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel updated this revision to Diff 58008.May 20 2016, 3:34 PM
spatel retitled this revision from to [ValueTracking, InstCombine] extend isKnownToBeAPowerOfTwo() to handle vector splat constants.
spatel updated this object.
spatel added reviewers: majnemer, sanjoy, hfinkel.
spatel added a subscriber: llvm-commits.
majnemer added inline comments.May 20 2016, 3:38 PM
lib/Analysis/ValueTracking.cpp
1504–1508 ↗(On Diff #58008)

I think you could use m_APInt to merge these cases together.

spatel updated this revision to Diff 58018.May 20 2016, 3:52 PM

Patch updated:
Today, I learned that m_APInt works for splats.
Thanks, David!

majnemer accepted this revision.May 20 2016, 3:58 PM
majnemer edited edge metadata.

LGTM

lib/Analysis/ValueTracking.cpp
1504 ↗(On Diff #58018)

I don't think you need to initialize this.

This revision is now accepted and ready to land.May 20 2016, 3:58 PM
This revision was automatically updated to reflect the committed changes.