diff --git a/mlir/test/Dialect/Vector/vector-warp-distribute.mlir b/mlir/test/Dialect/Vector/vector-warp-distribute.mlir --- a/mlir/test/Dialect/Vector/vector-warp-distribute.mlir +++ b/mlir/test/Dialect/Vector/vector-warp-distribute.mlir @@ -631,3 +631,29 @@ } return %r : f32 } + +// ----- + +// CHECK-PROP: func @incorrect_dependent_warp_propagate_read +func.func @incorrect_dependent_warp_propagate_read(%laneid: index, %src: memref<1x1024xf32>, %dest: memref<1x1024xf32>) { +// CHECK-PROP-NOT: warp_execute_on_lane_0 + + // Bug 1: mlir-opt -test-vector-warp-distribute=propagate-distribution -canonicalize + // This is incorrect, the first dimension of the load is only valid when %laneid is 0. + // The following produced IR reads out of bounds. + // We need to RAUW %laneid by %c0 inside warp_execute_on_lane_0 before any hoisting. + // + // CHECK-PROP-DAG: %[[R0:.*]] = vector.transfer_read %arg1[***BUG***%[[ID]], %[[ID]]], %{{.*}} : memref<1x1024xf32>, vector<1x1xf32> + // CHECK-PROP: vector.transfer_write %[[R0]], {{.*}} : vector<1x1xf32>, memref<1x1024xf32> + %c0 = arith.constant 0 : index + %cst = arith.constant 0.000000e+00 : f32 + %r = vector.warp_execute_on_lane_0(%laneid)[32] -> (vector<1x1xf32>) { + // Bug 2: mlir-opt -test-vector-warp-distribute=rewrite-warp-ops-to-scf-if -canonicalize -verify-each=0 + // Produces: %4 = "vector.load"(%3, %arg0) : (memref<1x32xf32, 3>, index) -> vector<1x1xf32> + // This fails verification since it needs 2 indices to load but only 1 is provided. + %2 = vector.transfer_read %src[%laneid, %c0], %cst : memref<1x1024xf32>, vector<1x32xf32> + vector.yield %2 : vector<1x32xf32> + } + vector.transfer_write %r, %dest[%c0, %laneid] : vector<1x1xf32>, memref<1x1024xf32> + return +}