Skip to content

Commit 0504531

Browse files
committed
add test
1 parent 4fff09e commit 0504531

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
3+
// See https://llvm.org/LICENSE.txt for license information.
4+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
//
6+
// (c) Copyright 2024 AMD Inc.
7+
8+
// RUN: aie-opt --aie-substitute-shim-dma-allocations %s
9+
10+
// Region simplification lead to compiler crashes previously if blocks/regions
11+
// had input arguments, such as created by scf.for loops with yield statements.
12+
// This test ensures that the compiler does not crash with such IR present.
13+
14+
module {
15+
aie.device(npu1_4col) {
16+
%tile_0_2 = aie.tile(0, 2)
17+
%buf = aie.buffer(%tile_0_2) : memref<32xi32>
18+
%buf0 = aie.buffer(%tile_0_2) : memref<32xi32>
19+
%buf1 = aie.buffer(%tile_0_2) : memref<32xi32>
20+
aie.core(%tile_0_2) {
21+
%c0 = index.constant 0
22+
%c2 = index.constant 2
23+
%val_i32 = memref.load %buf[%c0] : memref<32xi32>
24+
%val = index.castu %val_i32 : i32 to index
25+
%val_mod_2 = index.rems %val, %c2
26+
%cond = index.cmp eq(%val_mod_2, %c0)
27+
%res = scf.if %cond -> (memref<32xi32>) {
28+
scf.yield %buf0 : memref<32xi32>
29+
} else {
30+
scf.yield %buf1 : memref<32xi32>
31+
}
32+
%res_load = memref.load %res[%c0] : memref<32xi32>
33+
memref.store %res_load, %buf[%c0] : memref<32xi32>
34+
aie.end
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)