Skip to content

Commit

Permalink
[CIR] Add C source code as comments in for.cir unit test (#625)
Browse files Browse the repository at this point in the history
With C source code, we would able to update the CIR tests when needed.
  • Loading branch information
ShivaChen authored and lanza committed Nov 3, 2024
1 parent a025773 commit f30ba33
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions clang/test/CIR/Lowering/ThroughMLIR/for.cir
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
// RUN: cir-opt %s -cir-to-mlir --canonicalize | FileCheck %s -check-prefix=MLIR
// RUN: cir-opt %s -cir-to-mlir --canonicalize -cir-mlir-to-llvm | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM

// Note that the following CIR been produced after -cir-mlir-scf-prepare.
// So the loop invariant in the condition block have been hoisted out of loop.

!s32i = !cir.int<s, 32>
module {
cir.global external @a = #cir.zero : !cir.array<!s32i x 100>

// for (int i = 0; i < 100; ++i)
// a[i] = 3;
//
// MLIR-LABEL: func.func @constantLoopBound()
// LLVM-LABEL: define void @constantLoopBound()
cir.func @constantLoopBound() {
Expand Down Expand Up @@ -55,6 +61,9 @@ module {
cir.return
}

// for (int i = 0; i <= 100; ++i)
// a[i] = 3;
//
// MLIR-LABEL: func.func @constantLoopBound_LE()
// LLVM-LABEL: define void @constantLoopBound_LE()
cir.func @constantLoopBound_LE() {
Expand Down Expand Up @@ -105,6 +114,9 @@ module {
cir.return
}

// for (int i = l; i < u; ++i)
// a[i] = 3;
//
// MLIR-LABEL: func.func @variableLoopBound(%arg0: i32, %arg1: i32)
// LLVM-LABEL: define void @variableLoopBound(i32 %0, i32 %1)
cir.func @variableLoopBound(%arg0: !s32i, %arg1: !s32i) {
Expand Down Expand Up @@ -161,6 +173,9 @@ module {
cir.return
}

// for (int i = l; i <= u; i+=4)
// a[i] = 3;
//
// MLIR-LABEL: func.func @variableLoopBound_LE(%arg0: i32, %arg1: i32)
// LLVM-LABEL: define void @variableLoopBound_LE(i32 %0, i32 %1)
cir.func @variableLoopBound_LE(%arg0: !s32i, %arg1: !s32i) {
Expand Down

0 comments on commit f30ba33

Please sign in to comment.