This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Fold extractelement splat.
ClosedPublic

Authored by jacquesguan on Apr 1 2022, 8:39 PM.

Details

Summary

This revision supports to fold vector.extractelement (splat X) -> X.

Diff Detail

Event Timeline

jacquesguan created this revision.Apr 1 2022, 8:39 PM
Herald added a project: Restricted Project. · View Herald Transcript
jacquesguan requested review of this revision.Apr 1 2022, 8:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 8:39 PM
ftynse added inline comments.Apr 4 2022, 4:29 AM
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
954–956

Can't we? If we are extracting the element from a splat, isn't it always the same regardless of the position?

958

Nit: please use full sentences in comments, that is, start with a capital letter and end with a dot.

jacquesguan added inline comments.Apr 5 2022, 7:23 PM
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
954–956

But if the position exceeds the range of the vector, the result should be a poison value? Could we ignore this possibility?

ftynse added inline comments.Apr 7 2022, 8:27 AM
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
954–956

Good question. There is no poison semantics in MLIR. I would interpret accessing out of bounds as C-style UB, at which point folding it to the splat value is as valid as any other behavior.

ThomasRaoux added inline comments.Apr 7 2022, 10:21 AM
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
954–956

Address comment.

mlir/lib/Dialect/Vector/IR/VectorOps.cpp
954–956

Done, thanks.

ftynse accepted this revision.Apr 8 2022, 12:07 AM
This revision is now accepted and ready to land.Apr 8 2022, 12:07 AM
This revision was automatically updated to reflect the committed changes.