This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] fold low-bit mask of sext-in-reg
AbandonedPublic

Authored by spatel on Nov 12 2020, 9:35 AM.

Details

Summary

This is an alternative to D91343. I do not have stats for how often the shl+ashr pattern (sext-in-reg) occurs, but we have an SDAG node for that operation, so it seems common enough to warrant a dedicated fold for this pattern:
https://rise4fun.com/Alive/vI9

Diff Detail

Event Timeline

spatel created this revision.Nov 12 2020, 9:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 12 2020, 9:35 AM
spatel requested review of this revision.Nov 12 2020, 9:35 AM

I mildly prefer the other approach (D91343), because it doesn't hardcode the and instruction.

I mildly prefer the other approach (D91343), because it doesn't hardcode the and instruction.

Right, that's more flexible with potentially more compute known bits cost.
@Bhramar.vatsa - I committed the baseline tests shown here with 8a1e636. Please update/rebase your patch and confirm that you get the same diffs. I think you can reduce the code a bit too based on the match code shown here.

I mildly prefer the other approach (D91343), because it doesn't hardcode the and instruction.

Right, that's more flexible with potentially more compute known bits cost.

Ack.
But i think the pattern isn't *that* common, i would be surprised if this fires more than ~1k times as of vanilla test-suite.

@Bhramar.vatsa - I committed the baseline tests shown here with 8a1e636. Please update/rebase your patch and confirm that you get the same diffs. I think you can reduce the code a bit too based on the match code shown here.

spatel abandoned this revision.Nov 16 2020, 10:56 AM

Abandoning in favor of the more general D91343.