[Mlir-commits] [mlir] [MLIR] Implement emulation of static indexing subbyte type vector stores (PR #115922)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Jan 14 03:01:24 PST 2025
================
@@ -292,6 +296,100 @@ emulatedVectorLoad(OpBuilder &rewriter, Location loc, Value base,
newLoad);
}
+/// Downcast two values to `downcastType`, then select values
+/// based on `mask`, and casts the result to `upcastType`.
+static Value downcastSelectAndUpcast(OpBuilder &builder, Location loc,
+ VectorType downcastType,
+ VectorType upcastType, Value mask,
+ Value trueValue, Value falseValue) {
+ assert(
+ downcastType.getNumElements() * downcastType.getElementTypeBitWidth() ==
+ upcastType.getNumElements() * upcastType.getElementTypeBitWidth() &&
+ "expected upcastType size to be twice the size of downcastType");
+ if (trueValue.getType() != downcastType)
+ trueValue = builder.create<vector::BitCastOp>(loc, downcastType, trueValue);
+ if (falseValue.getType() != downcastType)
+ falseValue =
+ builder.create<vector::BitCastOp>(loc, downcastType, falseValue);
----------------
lialan wrote:
:-) You are right. But here I actually prefer having those checks if you don't mind, because generating something like:
```mlir
288: %8 = vector.bitcast %1 : vector<4xi2> to vector<4xi2>
```
actually adds more IR lines, so I personally love to make it a little bit cleaner :-)
https://github.com/llvm/llvm-project/pull/115922
More information about the Mlir-commits
mailing list