64 lines · plain
1// RUN: mlir-opt -convert-xegpu-to-xevm --split-input-file %s | FileCheck %s2 3// This file contains tests for materalization patterns added to handle custom type conversions4// added on top of LLVM type converter.5 6gpu.module @materializecast {7 // CHECK-LABEL: gpu.func @materialize_memref8 // CHECK-SAME: %[[ARG0:.*]]: memref<128xf32>9 gpu.func @materialize_memref(%src: memref<128xf32>) kernel {10 // CHECK: %[[INTPTR:.*]] = memref.extract_aligned_pointer_as_index %[[ARG0]] : memref<128xf32> -> index11 // CHECK: %[[CASTED:.*]] = arith.index_castui %[[INTPTR]] : index to i6412 %offset = arith.constant 0 : index13 %mask = arith.constant 1 : i114 %val = xegpu.load %src[%offset], %mask : memref<128xf32>, index, i1 -> f3215 gpu.return16 }17}18 19// -----20gpu.module @materializecast {21 // CHECK-LABEL: gpu.func @materialize_ui6422 // CHECK-SAME: %[[ARG0:.*]]: ui6423 gpu.func @materialize_ui64(%src: ui64) kernel {24 // CHECK: %[[VAR0:.*]] = index.castu %[[ARG0]] : ui64 to index25 // CHECK: %[[VAR1:.*]] = arith.index_castui %[[VAR0]] : index to i6426 %offset = arith.constant 0 : index27 %mask = arith.constant 1 : i128 %val = xegpu.load %src[%offset], %mask : ui64, index, i1 -> vector<1xf32>29 gpu.return30 }31}32 33// -----34gpu.module @materializecast {35 // CHECK-LABEL: gpu.func @materialize_ui3236 // CHECK-SAME: %[[ARG0:.*]]: ui3237 gpu.func @materialize_ui32(%src: ui32) kernel {38 // CHECK: %[[VAR0:.*]] = index.castu %[[ARG0]] : ui32 to index39 // CHECK: %[[VAR1:.*]] = arith.index_castui %[[VAR0]] : index to i3240 %offset = arith.constant 0 : index41 %mask = arith.constant 1 : i142 %val = xegpu.load %src[%offset], %mask : ui32, index, i1 -> vector<1xf32>43 gpu.return44 }45}46 47// -----48gpu.module @materializecast {49 // CHECK-LABEL: gpu.func @materialize_single_index_vector50 // CHECK-SAME: %[[ARG0:.*]]: memref<128xf32>51 gpu.func @materialize_single_index_vector(%src: memref<128xf32>) kernel {52 // CHECK: %[[CST:.*]] = arith.constant dense<0> : vector<1xindex>53 // CHECK: %[[VAR1:.*]] = vector.extract %[[CST]][0] : index from vector<1xindex>54 // CHECK: %[[VAR2:.*]] = arith.index_castui %[[VAR1]] : index to i6455 // CHECK: %[[CST1:.*]] = arith.constant dense<true> : vector<1xi1>56 // CHECK: %[[VAR3:.*]] = vector.extract %[[CST1]][0] : i1 from vector<1xi1>57 %offset = arith.constant dense<0> : vector<1xindex>58 %mask = arith.constant dense<1> : vector<1xi1>59 %val = xegpu.load %src[%offset], %mask : memref<128xf32>, vector<1xindex>, vector<1xi1> -> vector<1xf32>60 gpu.return61 }62}63 64