Page MenuHomePhabricator

[SCEV] Simplify zext/trunc idiom that appears when handling bitmasks.

Authored by jlebar on Jun 13 2018, 8:32 PM.



Specifically, we transform

zext(2^K * (trunc X to iN)) to iM ->
2^K * (zext(trunc X to i{N-K}) to iM)<nuw>

This is helpful because pulling the 2^K out of the zext allows further

Diff Detail


Event Timeline

jlebar created this revision.Jun 13 2018, 8:32 PM
sanjoy accepted this revision.Jun 14 2018, 10:01 AM


1771 ↗(On Diff #151300)

SA is a bad name for a SCEVMulExpr -- should be SM or Mul. Do you mind fixing this in a followup CL while you're here?

1800 ↗(On Diff #151300)

Let's s/TruncTy/NewTruncTy for consistency with NewTruncBits

1801 ↗(On Diff #151300)

Super minor issue - if NewTruncBits < 1 then IntegerType::get would have asserted already. If you want to keep this assert for the better error message it is probably better to put it before IntegerType::get.

This revision is now accepted and ready to land.Jun 14 2018, 10:01 AM
jlebar marked 3 inline comments as done.Jun 14 2018, 10:17 AM

Thank you for the reviews, Sanjoy!

Will push with your suggested changes.

1771 ↗(On Diff #151300)

Will do.

1801 ↗(On Diff #151300)

Sure, let's just remove this assert.

This revision was automatically updated to reflect the committed changes.
jlebar marked 2 inline comments as done.