Skip to content

Commit

Permalink
[CIR] Put loop body in nested scopes
Browse files Browse the repository at this point in the history
This patch puts for-loop body, while-loop body, and do-while-loop body in nested
scopes. Allocas in the loop body are now push down to the nested scope.

Resolve #1218 .
  • Loading branch information
Lancern committed Dec 10, 2024
1 parent 21e8647 commit 8063b5b
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 105 deletions.
16 changes: 7 additions & 9 deletions clang/lib/CIR/CodeGen/CIRGenStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,13 +910,9 @@ mlir::LogicalResult CIRGenFunction::emitForStmt(const ForStmt &S) {
},
/*bodyBuilder=*/
[&](mlir::OpBuilder &b, mlir::Location loc) {
// https://en.cppreference.com/w/cpp/language/for
// While in C++, the scope of the init-statement and the scope of
// statement are one and the same, in C the scope of statement is
// nested within the scope of init-statement.
bool useCurrentScope =
CGM.getASTContext().getLangOpts().CPlusPlus ? true : false;
if (emitStmt(S.getBody(), useCurrentScope).failed())
// The scope of the for loop body is nested within the scope of the
// for loop's init-statement and condition.
if (emitStmt(S.getBody(), /*useCurrentScope=*/false).failed())
loopRes = mlir::failure();
emitStopPoint(&S);
},
Expand Down Expand Up @@ -973,7 +969,8 @@ mlir::LogicalResult CIRGenFunction::emitDoStmt(const DoStmt &S) {
},
/*bodyBuilder=*/
[&](mlir::OpBuilder &b, mlir::Location loc) {
if (emitStmt(S.getBody(), /*useCurrentScope=*/true).failed())
// The scope of the do-while loop body is a nested scope.
if (emitStmt(S.getBody(), /*useCurrentScope=*/false).failed())
loopRes = mlir::failure();
emitStopPoint(&S);
});
Expand Down Expand Up @@ -1028,7 +1025,8 @@ mlir::LogicalResult CIRGenFunction::emitWhileStmt(const WhileStmt &S) {
},
/*bodyBuilder=*/
[&](mlir::OpBuilder &b, mlir::Location loc) {
if (emitStmt(S.getBody(), /*useCurrentScope=*/true).failed())
// The scope of the while loop body is a nested scope.
if (emitStmt(S.getBody(), /*useCurrentScope=*/false).failed())
loopRes = mlir::failure();
emitStopPoint(&S);
});
Expand Down
6 changes: 5 additions & 1 deletion clang/test/CIR/CodeGen/goto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,16 @@ int jumpIntoLoop(int* ar) {
// CHECK: ^bb[[#BLK6]]:
// CHECK: cir.br ^bb[[#COND:]]
// CHECK: ^bb[[#COND]]:
// CHECK: cir.brcond {{.*}} ^bb[[#BODY]], ^bb[[#EXIT:]]
// CHECK: cir.brcond {{.*}} ^bb[[#BLK8:]], ^bb[[#EXIT:]]
// CHECK: ^bb[[#BLK8]]:
// CHECK: cir.br ^bb[[#BODY]]
// CHECK: ^bb[[#BODY]]:
// CHECK: cir.br ^bb[[#COND]]
// CHECK: ^bb[[#EXIT]]:
// CHECK: cir.br ^bb[[#BLK7:]]
// CHECK: ^bb[[#BLK7]]:
// CHECK: cir.br ^bb[[#RETURN]]
// CHECK: }



Expand Down Expand Up @@ -222,6 +225,7 @@ int jumpFromLoop(int* ar) {
// CHECK: cir.br ^bb[[#RETURN2:]]
// CHECK: ^bb[[#RETURN2]]:
// CHECK: cir.return
// CHECK: }


void flatLoopWithNoTerminatorInFront(int* ptr) {
Expand Down
9 changes: 6 additions & 3 deletions clang/test/CIR/CodeGen/loop-scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ void l0(void) {
// CPPSCOPE: cir.func @_Z2l0v()
// CPPSCOPE-NEXT: cir.scope {
// CPPSCOPE-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["i", init] {alignment = 4 : i64}
// CPPSCOPE-NEXT: %1 = cir.alloca !s32i, !cir.ptr<!s32i>, ["j", init] {alignment = 4 : i64}
// CPPSCOPE-NEXT: %2 = cir.const #cir.int<0> : !s32i
// CPPSCOPE-NEXT: cir.store %2, %0 : !s32i, !cir.ptr<!s32i>
// CPPSCOPE-NEXT: %1 = cir.const #cir.int<0> : !s32i
// CPPSCOPE-NEXT: cir.store %1, %0 : !s32i, !cir.ptr<!s32i>
// CPPSCOPE-NEXT: cir.for : cond {

// CPPSCOPE: } body {
// CPPSCOPE-NEXT: cir.scope {
// CPPSCOPE-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["j", init] {alignment = 4 : i64}

// CSCOPE: cir.func @l0()
// CSCOPE-NEXT: cir.scope {
// CSCOPE-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["i", init] {alignment = 4 : i64}
Expand Down
130 changes: 77 additions & 53 deletions clang/test/CIR/CodeGen/loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ void l1() {
// CHECK-NEXT: %6 = cir.cmp(lt, %4, %5) : !s32i, !cir.bool
// CHECK-NEXT: cir.condition(%6)
// CHECK-NEXT: } body {
// CHECK-NEXT: %4 = cir.load %0 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %5 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %6 = cir.binop(add, %4, %5) nsw : !s32i
// CHECK-NEXT: cir.store %6, %0 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: %4 = cir.load %0 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %5 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %6 = cir.binop(add, %4, %5) nsw : !s32i
// CHECK-NEXT: cir.store %6, %0 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: }
// CHECK-NEXT: cir.yield
// CHECK-NEXT: } step {
// CHECK-NEXT: %4 = cir.load %2 : !cir.ptr<!s32i>, !s32i
Expand Down Expand Up @@ -57,10 +59,12 @@ void l2(bool cond) {
// CHECK-NEXT: %3 = cir.load %0 : !cir.ptr<!cir.bool>, !cir.bool
// CHECK-NEXT: cir.condition(%3)
// CHECK-NEXT: } do {
// CHECK-NEXT: %3 = cir.load %1 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %4 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %5 = cir.binop(add, %3, %4) nsw : !s32i
// CHECK-NEXT: cir.store %5, %1 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: %3 = cir.load %1 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %4 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %5 = cir.binop(add, %3, %4) nsw : !s32i
// CHECK-NEXT: cir.store %5, %1 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: }
// CHECK-NEXT: cir.yield
// CHECK-NEXT: }
// CHECK-NEXT: }
Expand All @@ -69,10 +73,12 @@ void l2(bool cond) {
// CHECK-NEXT: %[[#TRUE:]] = cir.const #true
// CHECK-NEXT: cir.condition(%[[#TRUE]])
// CHECK-NEXT: } do {
// CHECK-NEXT: %3 = cir.load %1 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %4 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %5 = cir.binop(add, %3, %4) nsw : !s32i
// CHECK-NEXT: cir.store %5, %1 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: %3 = cir.load %1 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %4 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %5 = cir.binop(add, %3, %4) nsw : !s32i
// CHECK-NEXT: cir.store %5, %1 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: }
// CHECK-NEXT: cir.yield
// CHECK-NEXT: }
// CHECK-NEXT: }
Expand All @@ -82,10 +88,12 @@ void l2(bool cond) {
// CHECK-NEXT: %4 = cir.cast(int_to_bool, %3 : !s32i), !cir.bool
// CHECK-NEXT: cir.condition(%4)
// CHECK-NEXT: } do {
// CHECK-NEXT: %3 = cir.load %1 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %4 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %5 = cir.binop(add, %3, %4) nsw : !s32i
// CHECK-NEXT: cir.store %5, %1 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: %3 = cir.load %1 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %4 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %5 = cir.binop(add, %3, %4) nsw : !s32i
// CHECK-NEXT: cir.store %5, %1 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: }
// CHECK-NEXT: cir.yield
// CHECK-NEXT: }
// CHECK-NEXT: }
Expand All @@ -106,10 +114,12 @@ void l3(bool cond) {
// CHECK: cir.func @_Z2l3b
// CHECK: cir.scope {
// CHECK-NEXT: cir.do {
// CHECK-NEXT: %3 = cir.load %1 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %4 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %5 = cir.binop(add, %3, %4) nsw : !s32i
// CHECK-NEXT: cir.store %5, %1 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: %3 = cir.load %1 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %4 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %5 = cir.binop(add, %3, %4) nsw : !s32i
// CHECK-NEXT: cir.store %5, %1 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: }
// CHECK-NEXT: cir.yield
// CHECK-NEXT: } while {
// CHECK-NEXT: %[[#TRUE:]] = cir.load %0 : !cir.ptr<!cir.bool>, !cir.bool
Expand All @@ -118,10 +128,12 @@ void l3(bool cond) {
// CHECK-NEXT: }
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: cir.do {
// CHECK-NEXT: %3 = cir.load %1 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %4 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %5 = cir.binop(add, %3, %4) nsw : !s32i
// CHECK-NEXT: cir.store %5, %1 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: %3 = cir.load %1 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %4 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %5 = cir.binop(add, %3, %4) nsw : !s32i
// CHECK-NEXT: cir.store %5, %1 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: }
// CHECK-NEXT: cir.yield
// CHECK-NEXT: } while {
// CHECK-NEXT: %[[#TRUE:]] = cir.const #true
Expand All @@ -130,10 +142,12 @@ void l3(bool cond) {
// CHECK-NEXT: }
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: cir.do {
// CHECK-NEXT: %3 = cir.load %1 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %4 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %5 = cir.binop(add, %3, %4) nsw : !s32i
// CHECK-NEXT: cir.store %5, %1 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: %3 = cir.load %1 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %4 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %5 = cir.binop(add, %3, %4) nsw : !s32i
// CHECK-NEXT: cir.store %5, %1 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: }
// CHECK-NEXT: cir.yield
// CHECK-NEXT: } while {
// CHECK-NEXT: %3 = cir.const #cir.int<1> : !s32i
Expand All @@ -157,18 +171,19 @@ void l4() {
// CHECK-NEXT: %[[#TRUE:]] = cir.const #true
// CHECK-NEXT: cir.condition(%[[#TRUE]])
// CHECK-NEXT: } do {
// CHECK-NEXT: %4 = cir.load %0 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %5 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %6 = cir.binop(add, %4, %5) nsw : !s32i
// CHECK-NEXT: cir.store %6, %0 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: %10 = cir.load %0 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %11 = cir.const #cir.int<10> : !s32i
// CHECK-NEXT: %12 = cir.cmp(lt, %10, %11) : !s32i, !cir.bool
// CHECK-NEXT: cir.if %12 {
// CHECK-NEXT: cir.continue
// CHECK-NEXT: %4 = cir.load %0 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %5 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: %6 = cir.binop(add, %4, %5) nsw : !s32i
// CHECK-NEXT: cir.store %6, %0 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: %10 = cir.load %0 : !cir.ptr<!s32i>, !s32i
// CHECK-NEXT: %11 = cir.const #cir.int<10> : !s32i
// CHECK-NEXT: %12 = cir.cmp(lt, %10, %11) : !s32i, !cir.bool
// CHECK-NEXT: cir.if %12 {
// CHECK-NEXT: cir.continue
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }

void l5() {
do {
Expand Down Expand Up @@ -200,7 +215,10 @@ void l6() {
// CHECK-NEXT: %[[#TRUE:]] = cir.const #true
// CHECK-NEXT: cir.condition(%[[#TRUE]])
// CHECK-NEXT: } do {
// CHECK-NEXT: cir.return
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: cir.return
// CHECK-NEXT: }
// CHECK-NEXT: cir.yield
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: cir.return
Expand All @@ -215,15 +233,18 @@ void unreachable_after_break() {

// CHECK-NEXT: cir.func @_Z23unreachable_after_breakv()
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {alignment = 4 : i64}
// CHECK-NEXT: cir.for : cond {
// CHECK-NEXT: %1 = cir.const #true
// CHECK-NEXT: cir.condition(%1)
// CHECK-NEXT: %0 = cir.const #true
// CHECK-NEXT: cir.condition(%0)
// CHECK-NEXT: } body {
// CHECK-NEXT: cir.break
// CHECK-NEXT: ^bb1: // no predecessors
// CHECK-NEXT: %1 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: cir.store %1, %0 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {alignment = 4 : i64}
// CHECK-NEXT: cir.break
// CHECK-NEXT: ^bb1: // no predecessors
// CHECK-NEXT: %1 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: cir.store %1, %0 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: cir.yield
// CHECK-NEXT: }
// CHECK-NEXT: cir.yield
// CHECK-NEXT: } step {
// CHECK-NEXT: cir.yield
Expand All @@ -241,15 +262,18 @@ void unreachable_after_continue() {

// CHECK-NEXT: cir.func @_Z26unreachable_after_continuev()
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {alignment = 4 : i64}
// CHECK-NEXT: cir.for : cond {
// CHECK-NEXT: %1 = cir.const #true
// CHECK-NEXT: cir.condition(%1)
// CHECK-NEXT: %0 = cir.const #true
// CHECK-NEXT: cir.condition(%0)
// CHECK-NEXT: } body {
// CHECK-NEXT: cir.continue
// CHECK-NEXT: ^bb1: // no predecessors
// CHECK-NEXT: %1 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: cir.store %1, %0 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: cir.scope {
// CHECK-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {alignment = 4 : i64}
// CHECK-NEXT: cir.continue
// CHECK-NEXT: ^bb1: // no predecessors
// CHECK-NEXT: %1 = cir.const #cir.int<1> : !s32i
// CHECK-NEXT: cir.store %1, %0 : !s32i, !cir.ptr<!s32i>
// CHECK-NEXT: cir.yield
// CHECK-NEXT: }
// CHECK-NEXT: cir.yield
// CHECK-NEXT: } step {
// CHECK-NEXT: cir.yield
Expand Down
62 changes: 33 additions & 29 deletions clang/test/CIR/Lowering/ThroughMLIR/doWhile.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ void nestedDoWhile() {
// CHECK: memref.store %[[C0_I32_2]], %[[ALLOC1]][] : memref<i32>
// CHECK: memref.alloca_scope {
// CHECK: scf.while : () -> () {
// CHECK: %[[VAR1:.+]] = memref.load %[[ALLOC1]][] : memref<i32>
// CHECK: %[[VAR2:.+]] = memref.load %[[ALLOC0]][] : memref<i32>
// CHECK: %[[ADD:.+]] = arith.addi %[[VAR2]], %[[VAR1]] : i32
// CHECK: memref.store %[[ADD]], %[[ALLOC0]][] : memref<i32>
// CHECK: %[[VAR3:.+]] = memref.load %[[ALLOC1]][] : memref<i32>
// CHECK: %[[C1_I32:.+]] = arith.constant 1 : i32
// CHECK: %[[ADD1:.+]] = arith.addi %[[VAR3]], %[[C1_I32]] : i32
// CHECK: memref.store %[[ADD1]], %[[ALLOC1]][] : memref<i32>
// CHECK: memref.alloca_scope {
// CHECK: %[[VAR1:.+]] = memref.load %[[ALLOC1]][] : memref<i32>
// CHECK: %[[VAR2:.+]] = memref.load %[[ALLOC0]][] : memref<i32>
// CHECK: %[[ADD:.+]] = arith.addi %[[VAR2]], %[[VAR1]] : i32
// CHECK: memref.store %[[ADD]], %[[ALLOC0]][] : memref<i32>
// CHECK: %[[VAR3:.+]] = memref.load %[[ALLOC1]][] : memref<i32>
// CHECK: %[[C1_I32:.+]] = arith.constant 1 : i32
// CHECK: %[[ADD1:.+]] = arith.addi %[[VAR3]], %[[C1_I32]] : i32
// CHECK: memref.store %[[ADD1]], %[[ALLOC1]][] : memref<i32>
// CHECK: }
// CHECK: %[[VAR4:.+]] = memref.load %[[ALLOC1]][] : memref<i32>
// CHECK: %[[C10_I32:.+]] = arith.constant 10 : i32
// CHECK: %[[CMP:.+]] = arith.cmpi sle, %[[VAR4]], %[[C10_I32]] : i32
Expand All @@ -60,28 +62,30 @@ void nestedDoWhile() {
// CHECK: %[[C0_I32:.+]] = arith.constant 0 : i32
// CHECK: memref.store %[[C0_I32]], %[[alloca]][] : memref<i32>
// CHECK: memref.alloca_scope {
// CHECK: %[[alloca_0:.+]] = memref.alloca() {alignment = 4 : i64} : memref<i32>
// CHECK: scf.while : () -> () {
// CHECK: %[[ZERO:.+]] = memref.load %[[alloca]][] : memref<i32>
// CHECK: %[[C1_I32:.+]] = arith.constant 1 : i32
// CHECK: %[[ONE:.+]] = arith.addi %[[ZERO]], %[[C1_I32]] : i32
// CHECK: memref.store %[[ONE]], %[[alloca]][] : memref<i32>
// CHECK: %[[C0_I32_1:.+]] = arith.constant 0 : i32
// CHECK: memref.store %[[C0_I32_1]], %[[alloca_0]][] : memref<i32>
// CHECK: memref.alloca_scope {
// CHECK: scf.while : () -> () {
// CHECK: %[[EIGHT:.+]] = memref.load %[[alloca_0]][] : memref<i32>
// CHECK: %[[C2_I32_3:.+]] = arith.constant 2 : i32
// CHECK: %[[NINE:.+]] = arith.cmpi slt, %[[EIGHT]], %[[C2_I32_3]] : i32
// CHECK: %[[TWELVE:.+]] = arith.extui %[[NINE]] : i1 to i8
// CHECK: %[[THIRTEEN:.+]] = arith.trunci %[[TWELVE]] : i8 to i1
// CHECK: scf.condition(%[[THIRTEEN]])
// CHECK: } do {
// CHECK: %[[EIGHT]] = memref.load %[[alloca_0]][] : memref<i32>
// CHECK: %[[C1_I32_3:.+]] = arith.constant 1 : i32
// CHECK: %[[NINE]] = arith.addi %[[EIGHT]], %[[C1_I32_3]] : i32
// CHECK: memref.store %[[NINE]], %[[alloca_0]][] : memref<i32>
// CHECK: scf.yield
// CHECK: memref.alloca_scope {
// CHECK: %[[alloca_0:.+]] = memref.alloca() {alignment = 4 : i64} : memref<i32>
// CHECK: %[[ZERO:.+]] = memref.load %[[alloca]][] : memref<i32>
// CHECK: %[[C1_I32:.+]] = arith.constant 1 : i32
// CHECK: %[[ONE:.+]] = arith.addi %[[ZERO]], %[[C1_I32]] : i32
// CHECK: memref.store %[[ONE]], %[[alloca]][] : memref<i32>
// CHECK: %[[C0_I32_1:.+]] = arith.constant 0 : i32
// CHECK: memref.store %[[C0_I32_1]], %[[alloca_0]][] : memref<i32>
// CHECK: memref.alloca_scope {
// CHECK: scf.while : () -> () {
// CHECK: %[[EIGHT:.+]] = memref.load %[[alloca_0]][] : memref<i32>
// CHECK: %[[C2_I32_3:.+]] = arith.constant 2 : i32
// CHECK: %[[NINE:.+]] = arith.cmpi slt, %[[EIGHT]], %[[C2_I32_3]] : i32
// CHECK: %[[TWELVE:.+]] = arith.extui %[[NINE]] : i1 to i8
// CHECK: %[[THIRTEEN:.+]] = arith.trunci %[[TWELVE]] : i8 to i1
// CHECK: scf.condition(%[[THIRTEEN]])
// CHECK: } do {
// CHECK: %[[EIGHT]] = memref.load %[[alloca_0]][] : memref<i32>
// CHECK: %[[C1_I32_3:.+]] = arith.constant 1 : i32
// CHECK: %[[NINE]] = arith.addi %[[EIGHT]], %[[C1_I32_3]] : i32
// CHECK: memref.store %[[NINE]], %[[alloca_0]][] : memref<i32>
// CHECK: scf.yield
// CHECK: }
// CHECK: }
// CHECK: }
// CHECK: %[[TWO:.+]] = memref.load %[[alloca]][] : memref<i32>
Expand Down
Loading

0 comments on commit 8063b5b

Please sign in to comment.