Page MenuHomePhabricator

[CVP] Remove ashr of -1 or 0
ClosedPublic

Authored by fwolff on Nov 13 2021, 2:32 PM.

Details

Summary

Fixes PR#52190. There is already a check for converting ashr instructions with non-negative left-hand sides into lshr; this patch adds an optimization to remove ashr altogether if the left-hand side is known to be in the range [-1, 1).

Diff Detail

Event Timeline

fwolff created this revision.Nov 13 2021, 2:32 PM
fwolff requested review of this revision.Nov 13 2021, 2:32 PM
reames accepted this revision.Nov 15 2021, 8:52 AM

LGTM with required changes made.

llvm/test/Transforms/CorrelatedValuePropagation/ashr.ll
121

Please add a couple of tests for edge cases. (e.g. ashr -2, X, ashr 1, X)

This revision is now accepted and ready to land.Nov 15 2021, 8:52 AM
fwolff updated this revision to Diff 387370.Nov 15 2021, 12:57 PM

Thanks for the review @reames! I've added another test to cover the edge cases. Can you commit this for me?

Thanks for the review @reames! I've added another test to cover the edge cases. Can you commit this for me?

Sure. To confirm, this is code you intend to contribute to llvm under the terms of the relevant licenses and agreements, and have the authority to agree to same?

Thanks for the review @reames! I've added another test to cover the edge cases. Can you commit this for me?

Sure. To confirm, this is code you intend to contribute to llvm under the terms of the relevant licenses and agreements, and have the authority to agree to same?

Yes. For commit attribution, you can use the same name and email as in commit 738e7f1231949ec248c1d8d154783338215613d1. Thanks!

This revision was automatically updated to reflect the committed changes.