blob: 46c62b339f2eda15ddad175525a7b9ee99e1f967 [file] [log] [blame]
// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-translate %s -cir-to-llvmir --target x86_64-unknown-linux-gnu --disable-cc-lowering | FileCheck %s -check-prefix=LLVM
!u32i = !cir.int<u, 32>
module {
cir.func @foo() {
%0 = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init] {alignment = 4 : i64}
%1 = cir.alloca !u32i, !cir.ptr<!u32i>, ["b", init] {alignment = 4 : i64}
%2 = cir.alloca !u32i, !cir.ptr<!u32i>, ["x", init] {alignment = 4 : i64}
%3 = cir.const #cir.int<2> : !u32i cir.store %3, %0 : !u32i, !cir.ptr<!u32i>
%4 = cir.const #cir.int<1> : !u32i cir.store %4, %1 : !u32i, !cir.ptr<!u32i>
%5 = cir.load %0 : !cir.ptr<!u32i>, !u32i
%6 = cir.load %1 : !cir.ptr<!u32i>, !u32i
%7 = cir.binop(mul, %5, %6) : !u32i
cir.store %7, %2 : !u32i, !cir.ptr<!u32i>
%8 = cir.load %2 : !cir.ptr<!u32i>, !u32i
%9 = cir.load %1 : !cir.ptr<!u32i>, !u32i
%10 = cir.binop(div, %8, %9) : !u32i
cir.store %10, %2 : !u32i, !cir.ptr<!u32i>
%11 = cir.load %2 : !cir.ptr<!u32i>, !u32i
%12 = cir.load %1 : !cir.ptr<!u32i>, !u32i
%13 = cir.binop(rem, %11, %12) : !u32i
cir.store %13, %2 : !u32i, !cir.ptr<!u32i>
%14 = cir.load %2 : !cir.ptr<!u32i>, !u32i
%15 = cir.load %1 : !cir.ptr<!u32i>, !u32i
%16 = cir.binop(add, %14, %15) : !u32i
cir.store %16, %2 : !u32i, !cir.ptr<!u32i>
%17 = cir.load %2 : !cir.ptr<!u32i>, !u32i
%18 = cir.load %1 : !cir.ptr<!u32i>, !u32i
%19 = cir.binop(sub, %17, %18) : !u32i
cir.store %19, %2 : !u32i, !cir.ptr<!u32i>
%26 = cir.load %2 : !cir.ptr<!u32i>, !u32i
%27 = cir.load %1 : !cir.ptr<!u32i>, !u32i
%28 = cir.binop(and, %26, %27) : !u32i
cir.store %28, %2 : !u32i, !cir.ptr<!u32i>
%29 = cir.load %2 : !cir.ptr<!u32i>, !u32i
%30 = cir.load %1 : !cir.ptr<!u32i>, !u32i
%31 = cir.binop(xor, %29, %30) : !u32i
cir.store %31, %2 : !u32i, !cir.ptr<!u32i>
%32 = cir.load %2 : !cir.ptr<!u32i>, !u32i
%33 = cir.load %1 : !cir.ptr<!u32i>, !u32i
%34 = cir.binop(or, %32, %33) : !u32i
cir.store %34, %2 : !u32i, !cir.ptr<!u32i>
%35 = cir.binop(add, %32, %33) sat: !u32i
%36 = cir.binop(sub, %32, %33) sat: !u32i
%37 = cir.binop(max, %32, %33) : !u32i
cir.return
}
}
// MLIR: = llvm.mul
// MLIR: = llvm.udiv
// MLIR: = llvm.urem
// MLIR: = llvm.add
// MLIR: = llvm.sub
// MLIR: = llvm.and
// MLIR: = llvm.xor
// MLIR: = llvm.or
// MLIR: = llvm.intr.uadd.sat{{.*}}(i32, i32) -> i32
// MLIR: = llvm.intr.usub.sat{{.*}}(i32, i32) -> i32
// MLIR: = llvm.intr.umax
// LLVM: = mul i32
// LLVM: = udiv i32
// LLVM: = urem i32
// LLVM: = add i32
// LLVM: = sub i32
// LLVM: = and i32
// LLVM: = xor i32
// LLVM: = or i32
// LLVM: = call i32 @llvm.uadd.sat.i32
// LLVM: = call i32 @llvm.usub.sat.i32
// LLVM: = call i32 @llvm.umax.i32