This is an archive of the discontinued LLVM Phabricator instance.

[X86][InstCombine] Add some constant folding for BZHI intrinsics
ClosedPublic

Authored by craig.topper on Jul 30 2017, 6:51 PM.

Details

Summary

This intrinsic clears the upper bits starting at a specified index. If the index is a constant we can do some simplifications.

This could be in InstSimplify, but we don't handle any target specific intrinsics there today.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Jul 30 2017, 6:51 PM
craig.topper edited the summary of this revision. (Show Details)
zvi accepted this revision.Jul 31 2017, 12:23 AM

LGTM with minor comments.

lib/Transforms/InstCombine/InstCombineCalls.cpp
2281 ↗(On Diff #108849)

Minor: this is not constant-folding - it's a simplification, so consider updating the comment.

test/Transforms/InstCombine/X86/x86-bmi-tbm.ll
212 ↗(On Diff #108849)

This is out of scope, but would combining to 'and i32 %a, 0xefffffff' be profitable? It would at least be friendlier to DemandedBits.

This revision is now accepted and ready to land.Jul 31 2017, 12:23 AM
RKSimon added inline comments.Jul 31 2017, 12:23 AM
lib/Transforms/InstCombine/InstCombineCalls.cpp
2282 ↗(On Diff #108849)

Can we support this case? It guarantees that the CF flag is set.

RKSimon edited edge metadata.Jul 31 2017, 12:37 AM

LGTM

lib/Transforms/InstCombine/InstCombineCalls.cpp
2282 ↗(On Diff #108849)

Sorry that was rubbish - yes we can fold this.

This revision was automatically updated to reflect the committed changes.