Skip to content

Commit 4e91da7

Browse files
committed
[CIR] Fix other tests for bitcast elimination
unary.c need side effects to avoid DCE
1 parent 0450e12 commit 4e91da7

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

clang/test/CIR/CodeGen/no-proto-fun-ptr.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ void check_noproto_ptr() {
99
// CHECK: cir.func no_proto @check_noproto_ptr()
1010
// CHECK: [[ALLOC:%.*]] = cir.alloca !cir.ptr<!cir.func<!void ()>>, !cir.ptr<!cir.ptr<!cir.func<!void ()>>>, ["fun", init] {alignment = 8 : i64}
1111
// CHECK: [[GGO:%.*]] = cir.get_global @empty : !cir.ptr<!cir.func<!void ()>>
12-
// CHECK: [[CAST:%.*]] = cir.cast(bitcast, [[GGO]] : !cir.ptr<!cir.func<!void ()>>), !cir.ptr<!cir.func<!void ()>>
13-
// CHECK: cir.store [[CAST]], [[ALLOC]] : !cir.ptr<!cir.func<!void ()>>, !cir.ptr<!cir.ptr<!cir.func<!void ()>>>
12+
// CHECK: cir.store [[GGO]], [[ALLOC]] : !cir.ptr<!cir.func<!void ()>>, !cir.ptr<!cir.ptr<!cir.func<!void ()>>>
1413
// CHECK: cir.return
1514

1615
void empty(void) {}

clang/test/CIR/CodeGen/unary.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33

44
void valueNegation(int i, short s, long l, float f, double d) {
55
// CHECK: cir.func @valueNegation(
6-
!i;
6+
i = !i;
77
// CHECK: %[[#INT:]] = cir.load %{{[0-9]+}} : !cir.ptr<!s32i>, !s32i
88
// CHECK: %[[#INT_TO_BOOL:]] = cir.cast(int_to_bool, %[[#INT]] : !s32i), !cir.bool
99
// CHECK: = cir.unary(not, %[[#INT_TO_BOOL]]) : !cir.bool, !cir.bool
10-
!s;
10+
s = !s;
1111
// CHECK: %[[#SHORT:]] = cir.load %{{[0-9]+}} : !cir.ptr<!s16i>, !s16i
1212
// CHECK: %[[#SHORT_TO_BOOL:]] = cir.cast(int_to_bool, %[[#SHORT]] : !s16i), !cir.bool
1313
// CHECK: = cir.unary(not, %[[#SHORT_TO_BOOL]]) : !cir.bool, !cir.bool
14-
!l;
14+
l = !l;
1515
// CHECK: %[[#LONG:]] = cir.load %{{[0-9]+}} : !cir.ptr<!s64i>, !s64i
1616
// CHECK: %[[#LONG_TO_BOOL:]] = cir.cast(int_to_bool, %[[#LONG]] : !s64i), !cir.bool
1717
// CHECK: = cir.unary(not, %[[#LONG_TO_BOOL]]) : !cir.bool, !cir.bool
18-
!f;
18+
f = !f;
1919
// CHECK: %[[#FLOAT:]] = cir.load %{{[0-9]+}} : !cir.ptr<!cir.float>, !cir.float
2020
// CHECK: %[[#FLOAT_TO_BOOL:]] = cir.cast(float_to_bool, %[[#FLOAT]] : !cir.float), !cir.bool
2121
// CHECK: %[[#FLOAT_NOT:]] = cir.unary(not, %[[#FLOAT_TO_BOOL]]) : !cir.bool, !cir.bool
2222
// CHECK: = cir.cast(bool_to_int, %[[#FLOAT_NOT]] : !cir.bool), !s32i
23-
!d;
23+
d = !d;
2424
// CHECK: %[[#DOUBLE:]] = cir.load %{{[0-9]+}} : !cir.ptr<!cir.double>, !cir.double
2525
// CHECK: %[[#DOUBLE_TO_BOOL:]] = cir.cast(float_to_bool, %[[#DOUBLE]] : !cir.double), !cir.bool
2626
// CHECK: %[[#DOUBLE_NOT:]] = cir.unary(not, %[[#DOUBLE_TO_BOOL]]) : !cir.bool, !cir.bool

0 commit comments

Comments
 (0)