This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Arith] Fold integer shift op with zero.
ClosedPublic

Authored by jacquesguan on Dec 28 2022, 7:07 PM.

Details

Summary

This revision folds arith.shrui, arith.shrsi and arith.shli with zero
rhs to lhs.

Diff Detail

Event Timeline

jacquesguan created this revision.Dec 28 2022, 7:07 PM
jacquesguan requested review of this revision.Dec 28 2022, 7:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 28 2022, 7:07 PM

Add missing check.

ftynse added inline comments.Dec 29 2022, 12:47 AM
mlir/test/Dialect/Arith/canonicalize.mlir
2112

Nit: don't pattern-match SSA value names, they are transient. Capture the name at its definition point instead with %[[NAME:.+]]

aartbik added inline comments.Dec 29 2022, 10:15 AM
mlir/test/Dialect/Arith/canonicalize.mlir
2112

+1

capturing the arguments is simple as well, e.g.

CHECK-LABEL: func.func @foldShli0(
CHECK-SAME: %[[A:.*]]: i64)
// CHECK: return %[[A]] : i64

Address comment.

mlir/test/Dialect/Arith/canonicalize.mlir
2112

Done, thanks.

ftynse accepted this revision.Dec 30 2022, 1:09 AM
This revision is now accepted and ready to land.Dec 30 2022, 1:09 AM
This revision was automatically updated to reflect the committed changes.