This is an archive of the discontinued LLVM Phabricator instance.

[mlir][spirv] Add some folders for spv.LogicalAnd/spv.LogicalOr
ClosedPublic

Authored by antiagainst on Feb 26 2020, 9:47 AM.

Details

Summary

This commit handles folding spv.LogicalAnd/spv.LogicalOr when
one of the operands is constant true/false.

Diff Detail

Event Timeline

antiagainst created this revision.Feb 26 2020, 9:47 AM
rriddle added inline comments.Feb 26 2020, 9:54 AM
mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
41

Is the template here really necessary? Also, please use getSplatValue<bool>() instead.

rriddle accepted this revision.Feb 26 2020, 9:56 AM
rriddle added inline comments.
mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
29

Would it be better to change this to something like:

static Optional<bool> getScalarOrSplatBoolAttr(Attribute boolAttr)

to avoid doing the same checks twice in each of the folders?

This revision is now accepted and ready to land.Feb 26 2020, 9:56 AM
rriddle added inline comments.Feb 26 2020, 9:57 AM
mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
27

The comment irVal seems to be out-of-date.

This revision was automatically updated to reflect the committed changes.

Oops. Pushed an older commit without squashing fixes...

antiagainst marked 4 inline comments as done.Feb 26 2020, 12:38 PM
mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
29

Good suggestion! Done.