Skip to content

Commit

Permalink
[mlir][vector] Disable Gather1DToConditionalLoads for scalable vectors (
Browse files Browse the repository at this point in the history
llvm#96049)

Pattern scalarizes vector.gather operations and is incorrect for
scalable vectors.
  • Loading branch information
c-rhodes authored Jun 20, 2024
1 parent fa08e97 commit cc145f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mlir/lib/Dialect/Vector/Transforms/LowerVectorGather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ struct Gather1DToConditionalLoads : OpRewritePattern<vector::GatherOp> {
if (resultTy.getRank() != 1)
return rewriter.notifyMatchFailure(op, "unsupported rank");

if (resultTy.isScalable())
return rewriter.notifyMatchFailure(op, "not a fixed-width vector");

Location loc = op.getLoc();
Type elemTy = resultTy.getElementType();
// Vector type with a single element. Used to generate `vector.loads`.
Expand Down
10 changes: 10 additions & 0 deletions mlir/test/Dialect/Vector/vector-gather-lowering.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,13 @@ func.func @strided_gather(%base : memref<100x3xf32>,
// CHECK: scf.if %[[MASK_3]] -> (vector<4xf32>)
// CHECK: %[[M_3:.*]] = vector.load %[[COLLAPSED]][%[[IDX_3]]] : memref<300xf32>, vector<1xf32>
// CHECK: %[[V_3:.*]] = vector.extract %[[M_3]][0] : f32 from vector<1xf32>

// CHECK-LABEL: @scalable_gather_1d
// CHECK-NOT: extract
// CHECK: vector.gather
// CHECK-NOT: extract
func.func @scalable_gather_1d(%base: tensor<?xf32>, %v: vector<[2]xindex>, %mask: vector<[2]xi1>, %pass_thru: vector<[2]xf32>) -> vector<[2]xf32> {
%c0 = arith.constant 0 : index
%0 = vector.gather %base[%c0][%v], %mask, %pass_thru : tensor<?xf32>, vector<[2]xindex>, vector<[2]xi1>, vector<[2]xf32> into vector<[2]xf32>
return %0 : vector<[2]xf32>
}

0 comments on commit cc145f4

Please sign in to comment.