[Mlir-commits] [mlir] [MLIR][GPU] Support bf16 and i1 gpu::shuffles to LLVMSPIRV conversion (PR #119675)

Victor Perez llvmlistbot at llvm.org
Fri Jan 3 01:09:23 PST 2025


================
@@ -286,30 +291,94 @@ struct GPUShuffleConversion final : ConvertOpToLLVMPattern<gpu::ShuffleOp> {
            val == getSubgroupSize(op);
   }
 
+  static bool needsBitCastOrExt(gpu::ShuffleOp op) {
+    Type type = op.getType(0);
+    return isa<BFloat16Type>(type) || type.isInteger(1);
+  }
+
+  static Type getBitCastOrExtTy(Type oldTy,
+                                ConversionPatternRewriter &rewriter) {
+    return TypeSwitch<Type, Type>(oldTy)
+        .Case<BFloat16Type>([&](auto) { return rewriter.getIntegerType(16); })
+        .Case<IntegerType>([&](auto intTy) -> Type {
----------------
victor-eds wrote:

I am not sure that would compile.

```cpp
        .Case([&](BFloat16Type) { return rewriter.getIntegerType(16); })
        .Case([&](IntegerType intTy) -> Type {
```

Is nicer IMO tho

https://github.com/llvm/llvm-project/pull/119675


More information about the Mlir-commits mailing list