| // 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 |
| |
| module { |
| cir.func @foo() { |
| %0 = cir.alloca !cir.float, !cir.ptr<!cir.float>, ["c"] {alignment = 4 : i64} |
| %1 = cir.alloca !cir.float, !cir.ptr<!cir.float>, ["d"] {alignment = 4 : i64} |
| %2 = cir.alloca !cir.float, !cir.ptr<!cir.float>, ["y", init] {alignment = 4 : i64} |
| %3 = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["e"] {alignment = 8 : i64} |
| %4 = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["f"] {alignment = 8 : i64} |
| %5 = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["g", init] {alignment = 8 : i64} |
| %6 = cir.load %0 : !cir.ptr<!cir.float>, !cir.float |
| %7 = cir.load %1 : !cir.ptr<!cir.float>, !cir.float |
| %8 = cir.binop(mul, %6, %7) : !cir.float |
| cir.store %8, %2 : !cir.float, !cir.ptr<!cir.float> |
| %9 = cir.load %2 : !cir.ptr<!cir.float>, !cir.float |
| %10 = cir.load %1 : !cir.ptr<!cir.float>, !cir.float |
| %11 = cir.binop(div, %9, %10) : !cir.float |
| cir.store %11, %2 : !cir.float, !cir.ptr<!cir.float> |
| %12 = cir.load %2 : !cir.ptr<!cir.float>, !cir.float |
| %13 = cir.load %1 : !cir.ptr<!cir.float>, !cir.float |
| %14 = cir.binop(add, %12, %13) : !cir.float |
| cir.store %14, %2 : !cir.float, !cir.ptr<!cir.float> |
| %15 = cir.load %2 : !cir.ptr<!cir.float>, !cir.float |
| %16 = cir.load %1 : !cir.ptr<!cir.float>, !cir.float |
| %17 = cir.binop(sub, %15, %16) : !cir.float |
| cir.store %17, %2 : !cir.float, !cir.ptr<!cir.float> |
| %18 = cir.load %3 : !cir.ptr<!cir.double>, !cir.double |
| %19 = cir.load %4 : !cir.ptr<!cir.double>, !cir.double |
| %20 = cir.binop(add, %18, %19) : !cir.double |
| cir.store %20, %5 : !cir.double, !cir.ptr<!cir.double> |
| %21 = cir.load %3 : !cir.ptr<!cir.double>, !cir.double |
| %22 = cir.load %4 : !cir.ptr<!cir.double>, !cir.double |
| %23 = cir.binop(sub, %21, %22) : !cir.double |
| cir.store %23, %5 : !cir.double, !cir.ptr<!cir.double> |
| %24 = cir.load %3 : !cir.ptr<!cir.double>, !cir.double |
| %25 = cir.load %4 : !cir.ptr<!cir.double>, !cir.double |
| %26 = cir.binop(mul, %24, %25) : !cir.double |
| cir.store %26, %5 : !cir.double, !cir.ptr<!cir.double> |
| %27 = cir.load %3 : !cir.ptr<!cir.double>, !cir.double |
| %28 = cir.load %4 : !cir.ptr<!cir.double>, !cir.double |
| %29 = cir.binop(div, %27, %28) : !cir.double |
| cir.store %29, %5 : !cir.double, !cir.ptr<!cir.double> |
| cir.return |
| } |
| } |
| |
| // MLIR: = llvm.alloca {{.*}} f32 {alignment = 4 : i64} : (i64) -> !llvm.ptr |
| // MLIR: = llvm.alloca {{.*}} f64 {alignment = 8 : i64} : (i64) -> !llvm.ptr |
| // MLIR: = llvm.fmul {{.*}} : f32 |
| // MLIR: = llvm.fdiv |
| // MLIR: = llvm.fadd |
| // MLIR: = llvm.fsub |
| // MLIR: = llvm.fadd {{.*}} : f64 |
| // MLIR: = llvm.fsub |
| // MLIR: = llvm.fmul |
| // MLIR: = llvm.fdiv |
| |
| // LLVM: = alloca float, i64 |
| // LLVM: = alloca double, i64 |
| // LLVM: = fmul float |
| // LLVM: = fdiv float |
| // LLVM: = fadd float |
| // LLVM: = fsub float |
| // LLVM: = fadd double |
| // LLVM: = fsub double |
| // LLVM: = fmul double |
| // LLVM: = fdiv double |