This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Commute sign extends through nsw additions
ClosedPublic

Authored by sanjoy on Oct 12 2015, 6:48 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

sanjoy updated this revision to Diff 37209.Oct 12 2015, 6:48 PM
sanjoy retitled this revision from to [SCEV] Commute sign extends through nsw additions.
sanjoy updated this object.
sanjoy added reviewers: atrick, hfinkel, reames, nlewycky.
sanjoy added a subscriber: llvm-commits.
nlewycky added inline comments.Oct 16 2015, 3:47 PM
lib/Analysis/ScalarEvolution.cpp
1634 ↗(On Diff #37209)

// sext(A +nsw B +nsw ... ) --> sext(A) +nsw sext(B) +nsw ...

1635–1637 ↗(On Diff #37209)

Any reason not to do this with zext and nuw?

sanjoy updated this revision to Diff 37652.Oct 16 2015, 4:20 PM
sanjoy marked an inline comment as done.
  • address review: add comment
lib/Analysis/ScalarEvolution.cpp
1635–1637 ↗(On Diff #37209)

No specific reason; we've only run into the sext case so far. If you think that it'll be good for symmetry, I can add a separate change for nuw by next week.

nlewycky accepted this revision.Oct 16 2015, 4:23 PM
nlewycky edited edge metadata.

LGTM, but please do the obvious thing with zext too. I don't feel like the zext tests will need my review, but you can ask me to look at them if you feel otherwise. Thanks for the patch!

lib/Analysis/ScalarEvolution.cpp
1635–1637 ↗(On Diff #37652)

Please do. You'll find the functions exceptionally symmetric already. :)

This revision is now accepted and ready to land.Oct 16 2015, 4:23 PM
This revision was automatically updated to reflect the committed changes.