Debian Codegraph @

clang/test/CIR/CodeGen/compound_assign.cpp

raw
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
3 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll
4 // RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
5 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll
6 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
7
8 int compound_assign(int b) {
9 int x = 1;
10 x *= b;
11 x /= b;
12 x %= b;
13 x += b;
14 x -= b;
15 x >>= b;
16 x <<= b;
17 x &= b;
18 x ^= b;
19 x |= b;
20 return x;
21 }
22
23 // CIR: cir.func{{.*}} @_Z15compound_assigni
24 // CIR: %[[MUL:.*]] = cir.binop(mul, %{{.*}}, %{{.*}}) nsw : !s32i
25 // CIR: cir.store{{.*}} %[[MUL]], %{{.*}} : !s32i, !cir.ptr<!s32i>
26 // CIR: %[[DIV:.*]] = cir.binop(div, %{{.*}}, %{{.*}}) : !s32i
27 // CIR: cir.store{{.*}} %[[DIV]], %{{.*}} : !s32i, !cir.ptr<!s32i>
28 // CIR: %[[REM:.*]] = cir.binop(rem, %{{.*}}, %{{.*}}) : !s32i
29 // CIR: cir.store{{.*}} %[[REM]], %{{.*}} : !s32i, !cir.ptr<!s32i>
30 // CIR: %[[ADD:.*]] = cir.binop(add, %{{.*}}, %{{.*}}) nsw : !s32i
31 // CIR: cir.store{{.*}} %[[ADD]], %{{.*}} : !s32i, !cir.ptr<!s32i>
32 // CIR: %[[SUB:.*]] = cir.binop(sub, %{{.*}}, %{{.*}}) nsw : !s32i
33 // CIR: cir.store{{.*}} %[[SUB]], %{{.*}} : !s32i, !cir.ptr<!s32i>
34 // CIR: %[[SHR:.*]] = cir.shift(right, %{{.*}} : !s32i, %{{.*}} : !s32i) -> !s32i
35 // CIR: cir.store{{.*}} %[[SHR]], %{{.*}} : !s32i, !cir.ptr<!s32i>
36 // CIR: %[[SHL:.*]] = cir.shift(left, %{{.*}} : !s32i, %{{.*}} : !s32i) -> !s32i
37 // CIR: cir.store{{.*}} %[[SHL]], %{{.*}} : !s32i, !cir.ptr<!s32i>
38 // CIR: %[[AND:.*]] = cir.binop(and, %{{.*}}, %{{.*}}) : !s32i
39 // CIR: cir.store{{.*}} %[[AND]], %{{.*}} : !s32i, !cir.ptr<!s32i>
40 // CIR: %[[XOR:.*]] = cir.binop(xor, %{{.*}}, %{{.*}}) : !s32i
41 // CIR: cir.store{{.*}} %[[XOR]], %{{.*}} : !s32i, !cir.ptr<!s32i>
42 // CIR: %[[OR:.*]] = cir.binop(or, %{{.*}}, %{{.*}}) : !s32i
43 // CIR: cir.store{{.*}} %[[OR]], %{{.*}} : !s32i, !cir.ptr<!s32i>
44
45 // LLVM: define {{.*}}i32 @_Z15compound_assigni
46 // LLVM: %[[MUL:.*]] = mul nsw i32 %{{.*}}, %{{.*}}
47 // LLVM: store i32 %[[MUL]], ptr %{{.*}}
48 // LLVM: %[[DIV:.*]] = sdiv i32 %{{.*}}, %{{.*}}
49 // LLVM: store i32 %[[DIV]], ptr %{{.*}}
50 // LLVM: %[[REM:.*]] = srem i32 %{{.*}}, %{{.*}}
51 // LLVM: store i32 %[[REM]], ptr %{{.*}}
52 // LLVM: %[[ADD:.*]] = add nsw i32 %{{.*}}, %{{.*}}
53 // LLVM: store i32 %[[ADD]], ptr %{{.*}}
54 // LLVM: %[[SUB:.*]] = sub nsw i32 %{{.*}}, %{{.*}}
55 // LLVM: store i32 %[[SUB]], ptr %{{.*}}
56 // LLVM: %[[SHR:.*]] = ashr i32 %{{.*}}, %{{.*}}
57 // LLVM: store i32 %[[SHR]], ptr %{{.*}}
58 // LLVM: %[[SHL:.*]] = shl i32 %{{.*}}, %{{.*}}
59 // LLVM: store i32 %[[SHL]], ptr %{{.*}}
60 // LLVM: %[[AND:.*]] = and i32 %{{.*}}, %{{.*}}
61 // LLVM: store i32 %[[AND]], ptr %{{.*}}
62 // LLVM: %[[XOR:.*]] = xor i32 %{{.*}}, %{{.*}}
63 // LLVM: store i32 %[[XOR]], ptr %{{.*}}
64 // LLVM: %[[OR:.*]] = or i32 %{{.*}}, %{{.*}}
65 // LLVM: store i32 %[[OR]], ptr %{{.*}}
66
67 // OGCG: define {{.*}}i32 @_Z15compound_assigni
68 // OGCG: %[[MUL:.*]] = mul nsw i32 %{{.*}}, %{{.*}}
69 // OGCG: store i32 %[[MUL]], ptr %{{.*}}
70 // OGCG: %[[DIV:.*]] = sdiv i32 %{{.*}}, %{{.*}}
71 // OGCG: store i32 %[[DIV]], ptr %{{.*}}
72 // OGCG: %[[REM:.*]] = srem i32 %{{.*}}, %{{.*}}
73 // OGCG: store i32 %[[REM]], ptr %{{.*}}
74 // OGCG: %[[ADD:.*]] = add nsw i32 %{{.*}}, %{{.*}}
75 // OGCG: store i32 %[[ADD]], ptr %{{.*}}
76 // OGCG: %[[SUB:.*]] = sub nsw i32 %{{.*}}, %{{.*}}
77 // OGCG: store i32 %[[SUB]], ptr %{{.*}}
78 // OGCG: %[[SHR:.*]] = ashr i32 %{{.*}}, %{{.*}}
79 // OGCG: store i32 %[[SHR]], ptr %{{.*}}
80 // OGCG: %[[SHL:.*]] = shl i32 %{{.*}}, %{{.*}}
81 // OGCG: store i32 %[[SHL]], ptr %{{.*}}
82 // OGCG: %[[AND:.*]] = and i32 %{{.*}}, %{{.*}}
83 // OGCG: store i32 %[[AND]], ptr %{{.*}}
84 // OGCG: %[[XOR:.*]] = xor i32 %{{.*}}, %{{.*}}
85 // OGCG: store i32 %[[XOR]], ptr %{{.*}}
86 // OGCG: %[[OR:.*]] = or i32 %{{.*}}, %{{.*}}
87 // OGCG: store i32 %[[OR]], ptr %{{.*}}