This is an archive of the discontinued LLVM Phabricator instance.

[KnownBits] Add methods for determining if KnownBits is a constant value
ClosedPublic

Authored by craig.topper on May 2 2017, 11:36 PM.

Details

Summary

This patch adds isConstant and getConstant for determining if KnownBits represents a constant value and to retrieve the value. Use them to simplify code.

Unfortunately SimplifyDemandedBits needs to check if DemandedMask is a subset of the known bits so we can't use isConstant there. Maybe we need to add a method like areDemandedBitsConstant?

Diff Detail

Event Timeline

craig.topper created this revision.May 2 2017, 11:36 PM
RKSimon edited edge metadata.May 3 2017, 5:57 AM

Unfortunately SimplifyDemandedBits needs to check if DemandedMask is a subset of the known bits so we can't use isConstant there. Maybe we need to add a method like areDemandedBitsConstant?

Would this be a KnowBits method or just a static helper wrapper inside InstCombineSimplifyDemanded.cpp ?

lib/Analysis/ConstantFolding.cpp
708

braces

I think TargetLowering.cpp needs it for its version of demanded bits too.

Remove braces

RKSimon accepted this revision.May 3 2017, 3:54 PM

LGTM

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