This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Canonicalize/fold select %x, 1, 0 to extui
ClosedPublic

Authored by wsmoses on Jan 2 2022, 8:52 PM.

Details

Summary

Two canonicalizations for select %x, 1, 0

If the return type is i1, return simply the condition %x, otherwise extui %x to the return type.

Diff Detail

Event Timeline

wsmoses created this revision.Jan 2 2022, 8:52 PM
wsmoses requested review of this revision.Jan 2 2022, 8:52 PM
mehdi_amini added inline comments.Jan 2 2022, 9:02 PM
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
862

Can we also support select %arg, %c0, %c1?
Maybe extui (xor %arg, true) ?

862

That adds an operation in the chain, but it also turns the ternary in a fairly simple binary sequence.

wsmoses updated this revision to Diff 396992.Jan 2 2022, 9:25 PM

Add not case

mehdi_amini accepted this revision.Jan 2 2022, 10:24 PM
This revision is now accepted and ready to land.Jan 2 2022, 10:24 PM
This revision was automatically updated to reflect the committed changes.