llvm / clangir

A new (MLIR based) high-level IR for clang.
https://clangir.org
Other
307 stars 84 forks source link

Single-operand vector shuffling #667

Open seven-mile opened 3 weeks ago

seven-mile commented 3 weeks ago

Mentioned in #613 .

Some times we need to do single-operand vector shuffling. LLVM uses the form shuffle(v, undef / poison, mask), while CIR currently uses shuffle(v, v, mask) as we don't have equivalent for undef / poison. This causes different emissions of IR. Not very critical problem though.

A direct approach will be add one equivalent. In #628 Bruno mentioned that

Btw, it's possible we might need an undef attribute someday, but up to now we should be good without one!

The other approaches include unifying the two forms in CIR with canonicalization (or at least something similar). Open for other ideas.

bcardosolopes commented 3 weeks ago

Alternatively, we could make the second operand to be optional, and teach verifier how to look into those if necessary