Debian Codegraph @

clang/test/CIR/Lowering/binop-fp.cir

raw
1 // RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
2 // RUN: cir-translate %s -cir-to-llvmir --target x86_64-unknown-linux-gnu --disable-cc-lowering | FileCheck %s -check-prefix=LLVM
3
4 module {
5 cir.func @foo() {
6 %0 = cir.alloca !cir.float, !cir.ptr<!cir.float>, ["c"] {alignment = 4 : i64}
7 %1 = cir.alloca !cir.float, !cir.ptr<!cir.float>, ["d"] {alignment = 4 : i64}
8 %2 = cir.alloca !cir.float, !cir.ptr<!cir.float>, ["y", init] {alignment = 4 : i64}
9 %3 = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["e"] {alignment = 8 : i64}
10 %4 = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["f"] {alignment = 8 : i64}
11 %5 = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["g", init] {alignment = 8 : i64}
12 %6 = cir.load %0 : !cir.ptr<!cir.float>, !cir.float
13 %7 = cir.load %1 : !cir.ptr<!cir.float>, !cir.float
14 %8 = cir.binop(mul, %6, %7) : !cir.float
15 cir.store %8, %2 : !cir.float, !cir.ptr<!cir.float>
16 %9 = cir.load %2 : !cir.ptr<!cir.float>, !cir.float
17 %10 = cir.load %1 : !cir.ptr<!cir.float>, !cir.float
18 %11 = cir.binop(div, %9, %10) : !cir.float
19 cir.store %11, %2 : !cir.float, !cir.ptr<!cir.float>
20 %12 = cir.load %2 : !cir.ptr<!cir.float>, !cir.float
21 %13 = cir.load %1 : !cir.ptr<!cir.float>, !cir.float
22 %14 = cir.binop(add, %12, %13) : !cir.float
23 cir.store %14, %2 : !cir.float, !cir.ptr<!cir.float>
24 %15 = cir.load %2 : !cir.ptr<!cir.float>, !cir.float
25 %16 = cir.load %1 : !cir.ptr<!cir.float>, !cir.float
26 %17 = cir.binop(sub, %15, %16) : !cir.float
27 cir.store %17, %2 : !cir.float, !cir.ptr<!cir.float>
28 %18 = cir.load %3 : !cir.ptr<!cir.double>, !cir.double
29 %19 = cir.load %4 : !cir.ptr<!cir.double>, !cir.double
30 %20 = cir.binop(add, %18, %19) : !cir.double
31 cir.store %20, %5 : !cir.double, !cir.ptr<!cir.double>
32 %21 = cir.load %3 : !cir.ptr<!cir.double>, !cir.double
33 %22 = cir.load %4 : !cir.ptr<!cir.double>, !cir.double
34 %23 = cir.binop(sub, %21, %22) : !cir.double
35 cir.store %23, %5 : !cir.double, !cir.ptr<!cir.double>
36 %24 = cir.load %3 : !cir.ptr<!cir.double>, !cir.double
37 %25 = cir.load %4 : !cir.ptr<!cir.double>, !cir.double
38 %26 = cir.binop(mul, %24, %25) : !cir.double
39 cir.store %26, %5 : !cir.double, !cir.ptr<!cir.double>
40 %27 = cir.load %3 : !cir.ptr<!cir.double>, !cir.double
41 %28 = cir.load %4 : !cir.ptr<!cir.double>, !cir.double
42 %29 = cir.binop(div, %27, %28) : !cir.double
43 cir.store %29, %5 : !cir.double, !cir.ptr<!cir.double>
44 cir.return
45 }
46 }
47
48 // MLIR: = llvm.alloca {{.*}} f32 {alignment = 4 : i64} : (i64) -> !llvm.ptr
49 // MLIR: = llvm.alloca {{.*}} f64 {alignment = 8 : i64} : (i64) -> !llvm.ptr
50 // MLIR: = llvm.fmul {{.*}} : f32
51 // MLIR: = llvm.fdiv
52 // MLIR: = llvm.fadd
53 // MLIR: = llvm.fsub
54 // MLIR: = llvm.fadd {{.*}} : f64
55 // MLIR: = llvm.fsub
56 // MLIR: = llvm.fmul
57 // MLIR: = llvm.fdiv
58
59 // LLVM: = alloca float, i64
60 // LLVM: = alloca double, i64
61 // LLVM: = fmul float
62 // LLVM: = fdiv float
63 // LLVM: = fadd float
64 // LLVM: = fsub float
65 // LLVM: = fadd double
66 // LLVM: = fsub double
67 // LLVM: = fmul double
68 // LLVM: = fdiv double