Skip to content

Commit 2ea4005

Browse files
RiverDavetommymcm
andauthored
[CIR] Use poison as second vector operand in unary shuffles. (#1891)
First noted at: #1829 Also: Adjusted test cases affected by this change. --------- Co-authored-by: Tommy MᶜMichen <[email protected]>
1 parent a896c41 commit 2ea4005

File tree

4 files changed

+147
-104
lines changed

4 files changed

+147
-104
lines changed

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -991,9 +991,11 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
991991

992992
cir::VecShuffleOp createVecShuffle(mlir::Location loc, mlir::Value vec1,
993993
llvm::ArrayRef<int64_t> mask) {
994-
// FIXME(cir): Support use cir.vec.shuffle with single vec
995-
// Workaround: pass Vec as both vec1 and vec2
996-
return createVecShuffle(loc, vec1, vec1, mask);
994+
/// Create a unary shuffle. The second vector operand of the IR instruction
995+
/// is poison.
996+
return createVecShuffle(
997+
loc, vec1, getConstant(loc, cir::PoisonAttr::get(vec1.getType())),
998+
mask);
997999
}
9981000

9991001
cir::StoreOp

clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,13 +1031,8 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned BuiltinID,
10311031
for (unsigned i = 0; i != dstNumElts; ++i)
10321032
indices[i] = (i >= srcNumElts) ? srcNumElts + (i % srcNumElts) : i;
10331033

1034-
cir::ConstantOp poisonVec =
1035-
builder.getConstant(getLoc(E->getExprLoc()),
1036-
builder.getAttr<cir::PoisonAttr>(Ops[1].getType()));
1037-
1038-
mlir::Value op1 =
1039-
builder.createVecShuffle(getLoc(E->getExprLoc()), Ops[1], poisonVec,
1040-
ArrayRef(indices, dstNumElts));
1034+
mlir::Value op1 = builder.createVecShuffle(getLoc(E->getExprLoc()), Ops[1],
1035+
ArrayRef(indices, dstNumElts));
10411036

10421037
for (unsigned i = 0; i != dstNumElts; ++i) {
10431038
if (i >= index && i < (index + srcNumElts))

0 commit comments

Comments
 (0)