This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Canonicalization of Integer Cast Operations
ClosedPublic

Authored by wsmoses on May 1 2021, 9:40 PM.

Diff Detail

Event Timeline

wsmoses created this revision.May 1 2021, 9:40 PM
wsmoses requested review of this revision.May 1 2021, 9:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 1 2021, 9:40 PM
bondhugula requested changes to this revision.May 1 2021, 11:02 PM
bondhugula added a subscriber: bondhugula.

Please expand the commit summary to a line or two at least. It really doesn't summarize the canonicalization part.

mlir/lib/Dialect/StandardOps/IR/Ops.cpp
1245

Missing doc comment.

1471–1472

Please use dyn_cast - will lead to one check less with assertions enabled and more compact.

2731–2732

Likewise.

mlir/test/Dialect/Standard/canonicalize.mlir
406–410

This looks wrong to me. You don't get the same bits in index without doing the sign extension?

431

Missing new line at end of file.

This revision now requires changes to proceed.May 1 2021, 11:02 PM
wsmoses updated this revision to Diff 342222.May 1 2021, 11:13 PM

Use dyn_cast and add comments to commit

wsmoses marked 5 inline comments as done.May 1 2021, 11:15 PM

The commit message has been revised to the following (though apparently not updating on Phabricator summary):

Author: William S. Moses <gh@wsmoses.com>
Date:   Sun May 2 00:39:45 2021 -0400

    [MLIR] Canonicalization of Integer Cast Operations
    
    1) Canonicalize IndexCast(SExt(x)) => IndexCast(x)
    2) Provide constant folds of sign_extend and truncate
    
    Differential Revision: https://reviews.llvm.org/D101714
mlir/test/Dialect/Standard/canonicalize.mlir
406–410

From my reading of the lang ref (https://mlir.llvm.org/docs/Dialects/Standard/#stdindex_cast-indexcastop), this should be correct. Namely, index_cast is itself defined to be a sign extension so it is fine to fold the other extension into it.

The phab summary will have to be updated manually.

mlir/test/Dialect/Standard/canonicalize.mlir
406–410

You are right!

bondhugula accepted this revision.May 2 2021, 1:39 AM
This revision is now accepted and ready to land.May 2 2021, 1:39 AM

arc diff --verbatim updates the summary on Phab FYI

This revision was automatically updated to reflect the committed changes.
wsmoses marked an inline comment as done.