Skip to content

Commit d815e84

Browse files
authored
[CIR] Implement simple folding for integer casts (llvm#174861)
This extends the CastOp folder to handle integral casts between different integer types. This only handles scalar values at this time. This is in preparation for a change that will attempt to fold casts as they are generated, but this change only performs the folding via the cir-canonicalize pass.
1 parent 4912004 commit d815e84

16 files changed

Lines changed: 174 additions & 73 deletions

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,6 @@ OpFoldResult cir::CastOp::fold(FoldAdaptor adaptor) {
705705
if (getSrc().getType() == getType()) {
706706
switch (getKind()) {
707707
case cir::CastKind::integral: {
708-
// TODO: for sign differences, it's possible in certain conditions to
709-
// create a new attribute that's capable of representing the source.
710708
llvm::SmallVector<mlir::OpFoldResult, 1> foldResults;
711709
auto foldOrder = getSrc().getDefiningOp()->fold(foldResults);
712710
if (foldOrder.succeeded() && mlir::isa<mlir::Attribute>(foldResults[0]))
@@ -723,7 +721,36 @@ OpFoldResult cir::CastOp::fold(FoldAdaptor adaptor) {
723721
return {};
724722
}
725723
}
726-
return tryFoldCastChain(*this);
724+
725+
// Handle cases where a chain of casts cancel out.
726+
Value result = tryFoldCastChain(*this);
727+
if (result)
728+
return result;
729+
730+
// Handle simple constant casts.
731+
if (auto srcConst = getSrc().getDefiningOp<cir::ConstantOp>()) {
732+
switch (getKind()) {
733+
case cir::CastKind::integral: {
734+
mlir::Type srcTy = getSrc().getType();
735+
// Don't try to fold vector casts for now.
736+
assert(mlir::isa<cir::VectorType>(srcTy) ==
737+
mlir::isa<cir::VectorType>(getType()));
738+
if (mlir::isa<cir::VectorType>(srcTy))
739+
break;
740+
741+
auto srcIntTy = mlir::cast<cir::IntType>(srcTy);
742+
auto dstIntTy = mlir::cast<cir::IntType>(getType());
743+
APInt newVal =
744+
srcIntTy.isSigned()
745+
? srcConst.getIntValue().sextOrTrunc(dstIntTy.getWidth())
746+
: srcConst.getIntValue().zextOrTrunc(dstIntTy.getWidth());
747+
return cir::IntAttr::get(dstIntTy, newVal);
748+
}
749+
default:
750+
break;
751+
}
752+
}
753+
return {};
727754
}
728755

729756
//===----------------------------------------------------------------------===//

clang/test/CIR/CodeGen/aapcs-volatile-bitfields.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,10 @@ void check_store(st2 *s2) {
179179
}
180180

181181
// CIR: cir.func {{.*}} @check_store
182-
// CIR: [[CONST:%.*]] = cir.const #cir.int<1> : !s32i
183-
// CIR: [[CAST:%.*]] = cir.cast integral [[CONST]] : !s32i -> !s16i
182+
// CIR: [[CONST:%.*]] = cir.const #cir.int<1> : !s16i
184183
// CIR: [[LOAD:%.*]] = cir.load align(8) {{.*}} : !cir.ptr<!cir.ptr<!rec_st2>>, !cir.ptr<!rec_st2>
185184
// CIR: [[MEMBER:%.*]] = cir.get_member [[LOAD]][0] {name = "a"} : !cir.ptr<!rec_st2> -> !cir.ptr<!u32i>
186-
// CIR: [[SETBF:%.*]] = cir.set_bitfield align(8) (#bfi_a, [[MEMBER]] : !cir.ptr<!u32i>, [[CAST]] : !s16i) {is_volatile} -> !s16i
185+
// CIR: [[SETBF:%.*]] = cir.set_bitfield align(8) (#bfi_a, [[MEMBER]] : !cir.ptr<!u32i>, [[CONST]] : !s16i) {is_volatile} -> !s16i
187186
// CIR: cir.return
188187

189188
// LLVM:define dso_local void @check_store
@@ -210,11 +209,10 @@ void check_store_exception(st3 *s3) {
210209
}
211210

212211
// CIR: cir.func {{.*}} @check_store_exception
213-
// CIR: [[CONST:%.*]] = cir.const #cir.int<2> : !s32i
214-
// CIR: [[CAST:%.*]] = cir.cast integral [[CONST]] : !s32i -> !u32i
212+
// CIR: [[CONST:%.*]] = cir.const #cir.int<2> : !u32i
215213
// CIR: [[LOAD:%.*]] = cir.load align(8) {{.*}} : !cir.ptr<!cir.ptr<!rec_st3>>, !cir.ptr<!rec_st3>
216214
// CIR: [[MEMBER:%.*]] = cir.get_member [[LOAD]][2] {name = "b"} : !cir.ptr<!rec_st3> -> !cir.ptr<!u8i>
217-
// CIR: [[SETBF:%.*]] = cir.set_bitfield align(4) (#bfi_b1, [[MEMBER]] : !cir.ptr<!u8i>, [[CAST]] : !u32i) {is_volatile} -> !u32i
215+
// CIR: [[SETBF:%.*]] = cir.set_bitfield align(4) (#bfi_b1, [[MEMBER]] : !cir.ptr<!u8i>, [[CONST]] : !u32i) {is_volatile} -> !u32i
218216
// CIR: cir.return
219217

220218
// LLVM:define dso_local void @check_store_exception
@@ -262,11 +260,10 @@ void check_store_second_member (st4 *s4) {
262260
}
263261

264262
// CIR: cir.func {{.*}} @check_store_second_member
265-
// CIR: [[ONE:%.*]] = cir.const #cir.int<1> : !s32i
266-
// CIR: [[CAST:%.*]] = cir.cast integral [[ONE]] : !s32i -> !u64i
263+
// CIR: [[ONE:%.*]] = cir.const #cir.int<1> : !u64i
267264
// CIR: [[LOAD:%.*]] = cir.load align(8) {{.*}} : !cir.ptr<!cir.ptr<!rec_st4>>, !cir.ptr<!rec_st4>
268265
// CIR: [[MEMBER:%.*]] = cir.get_member [[LOAD]][2] {name = "b"} : !cir.ptr<!rec_st4> -> !cir.ptr<!u16i>
269-
// CIR: cir.set_bitfield align(8) (#bfi_b2, [[MEMBER]] : !cir.ptr<!u16i>, [[CAST]] : !u64i) {is_volatile} -> !u64i
266+
// CIR: cir.set_bitfield align(8) (#bfi_b2, [[MEMBER]] : !cir.ptr<!u16i>, [[ONE]] : !u64i) {is_volatile} -> !u64i
270267

271268
// LLVM: define dso_local void @check_store_second_member
272269
// LLVM: [[LOAD:%.*]] = load ptr, ptr {{.*}}, align 8

clang/test/CIR/CodeGen/assign-operator.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ void a() {
1616
// CIR: cir.func {{.*}} @_ZN1xaSEi(!cir.ptr<!rec_x>, !s32i)
1717
// CIR: cir.func{{.*}} @_Z1av()
1818
// CIR: %[[A_ADDR:.*]] = cir.alloca !rec_x, !cir.ptr<!rec_x>, ["a"]
19-
// CIR: %[[ONE:.*]] = cir.const #cir.int<1> : !u32i
20-
// CIR: %[[ONE_CAST:.*]] = cir.cast integral %[[ONE]] : !u32i -> !s32i
21-
// CIR: %[[RET:.*]] = cir.call @_ZN1xaSEi(%[[A_ADDR]], %[[ONE_CAST]]) : (!cir.ptr<!rec_x>, !s32i) -> !s32i
19+
// CIR: %[[ONE:.*]] = cir.const #cir.int<1> : !s32i
20+
// CIR: %[[RET:.*]] = cir.call @_ZN1xaSEi(%[[A_ADDR]], %[[ONE]]) : (!cir.ptr<!rec_x>, !s32i) -> !s32i
2221

2322
// LLVM: define{{.*}} @_Z1av(){{.*}}
2423
// OGCG: define{{.*}} @_Z1av()

clang/test/CIR/CodeGen/binassign.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ void binary_assign(void) {
2424
// CIR: %[[I:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["i"]
2525
// CIR: %[[TRUE:.*]] = cir.const #true
2626
// CIR: cir.store{{.*}} %[[TRUE]], %[[B]] : !cir.bool, !cir.ptr<!cir.bool>
27-
// CIR: %[[CHAR_INI_INIT:.*]] = cir.const #cir.int<65> : !s32i
28-
// CIR: %[[CHAR_VAL:.*]] = cir.cast integral %[[CHAR_INI_INIT]] : !s32i -> !s8i
27+
// CIR: %[[CHAR_VAL:.*]] = cir.const #cir.int<65> : !s8i
2928
// CIR: cir.store{{.*}} %[[CHAR_VAL]], %[[C]] : !s8i, !cir.ptr<!s8i>
3029
// CIR: %[[FLOAT_VAL:.*]] = cir.const #cir.fp<3.140000e+00> : !cir.float
3130
// CIR: cir.store{{.*}} %[[FLOAT_VAL]], %[[F]] : !cir.float, !cir.ptr<!cir.float>

clang/test/CIR/CodeGen/comma.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ void comma(void) {
2323
// CIR: %[[I:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["i"]
2424
// CIR: %[[TRUE:.*]] = cir.const #true
2525
// CIR: cir.store{{.*}} %[[TRUE]], %[[B]] : !cir.bool, !cir.ptr<!cir.bool>
26-
// CIR: %[[CHAR_INI_INIT:.*]] = cir.const #cir.int<65> : !s32i
27-
// CIR: %[[CHAR_VAL:.*]] = cir.cast integral %[[CHAR_INI_INIT]] : !s32i -> !s8i
26+
// CIR: %[[CHAR_VAL:.*]] = cir.const #cir.int<65> : !s8i
2827
// CIR: cir.store{{.*}} %[[CHAR_VAL]], %[[C]] : !s8i, !cir.ptr<!s8i>
2928
// CIR: %[[FLOAT_VAL:.*]] = cir.const #cir.fp<3.140000e+00> : !cir.float
3029
// CIR: cir.store{{.*}} %[[FLOAT_VAL]], %[[F]] : !cir.float, !cir.ptr<!cir.float>

clang/test/CIR/CodeGen/cxx-default-init.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,8 @@ struct ValueInit {
168168
// CIR: %[[FOUR_FIVEI:.*]] = cir.const #cir.const_complex<#cir.fp<6.000000e+00> : !cir.float, #cir.fp<7.000000e+00>
169169
// CIR: cir.store{{.*}} %[[FOUR_FIVEI]], %[[C]]
170170
// CIR: %[[BF:.*]] = cir.get_member %[[THIS]][4] {name = "bf"}
171-
// CIR: %[[FF:.*]] = cir.const #cir.int<255> : !s32i
172-
// CIR: %[[FF_CAST:.*]] = cir.cast integral %[[FF]] : !s32i -> !u32i
173-
// CIR: %[[BF_VAL:.*]] = cir.set_bitfield{{.*}} (#bfi_bf, %[[BF]] : !cir.ptr<!u8i>, %[[FF_CAST]] : !u32i)
171+
// CIR: %[[FF:.*]] = cir.const #cir.int<255> : !u32i
172+
// CIR: %[[BF_VAL:.*]] = cir.set_bitfield{{.*}} (#bfi_bf, %[[BF]] : !cir.ptr<!u8i>, %[[FF]] : !u32i)
174173

175174
// LLVM: define{{.*}} void @_ZN9ValueInitC2Ev(ptr %[[THIS_ARG:.*]])
176175
// LLVM: %[[THIS_ALLOCA:.*]] = alloca ptr

clang/test/CIR/CodeGen/enum.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ int f() {
1313
}
1414

1515
// CHECK: cir.func{{.*}} @_Z1fv
16-
// CHECK: cir.const #cir.int<1> : !u32i
16+
// CHECK: cir.const #cir.int<1> : !s32i
1717

1818
namespace test {
1919
using enum Numbers;
@@ -24,4 +24,4 @@ int f2() {
2424
}
2525

2626
// CHECK: cir.func{{.*}} @_Z2f2v
27-
// CHECK: cir.const #cir.int<2> : !u32i
27+
// CHECK: cir.const #cir.int<2> : !s32i

clang/test/CIR/CodeGen/finegrain-bitfield-access.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ void write8_1() {
6969
}
7070

7171
// CIR-LABEL: @_Z8write8_1v
72-
// CIR: [[CONST3:%.*]] = cir.const #cir.int<3> : !s32i
73-
// CIR: [[INT3:%.*]] = cir.cast integral [[CONST3]] : !s32i -> !u32i
72+
// CIR: [[CONST3:%.*]] = cir.const #cir.int<3> : !u32i
7473
// CIR: [[MEMBER:%.*]] = cir.get_member {{.*}}[1] {name = "f3"} : !cir.ptr<!rec_S1> -> !cir.ptr<!u8i>
75-
// CIR: cir.set_bitfield align(1) (#bfi_f3, [[MEMBER]] : !cir.ptr<!u8i>, [[INT3]] : !u32i) -> !u32i
74+
// CIR: cir.set_bitfield align(1) (#bfi_f3, [[MEMBER]] : !cir.ptr<!u8i>, [[CONST3]] : !u32i) -> !u32i
7675

7776
// LLVM-LABEL: @_Z8write8_1v
7877
// LLVM: store i8 3, ptr getelementptr inbounds nuw (i8, ptr {{.*}}, i64 1), align 1
@@ -115,10 +114,9 @@ void write8_2() {
115114
}
116115

117116
// CIR-LABEL: @_Z8write8_2v
118-
// CIR: [[CONST3:%.*]] = cir.const #cir.int<3> : !s32i
119-
// CIR: [[INT3:%.*]] = cir.cast integral [[CONST3]] : !s32i -> !u32i
117+
// CIR: [[CONST3:%.*]] = cir.const #cir.int<3> : !u32i
120118
// CIR: [[MEMBER:%.*]] = cir.get_member {{.*}}[2] {name = "f5"} : !cir.ptr<!rec_S1> -> !cir.ptr<!u16i>
121-
// CIR: cir.set_bitfield align(2) (#bfi_f5, %3 : !cir.ptr<!u16i>, {{.*}} : !u32i) -> !u32i
119+
// CIR: cir.set_bitfield align(2) (#bfi_f5, [[MEMBER]] : !cir.ptr<!u16i>, [[CONST3]] : !u32i) -> !u32i
122120

123121
// LLVM-LABEL: @_Z8write8_2v
124122
// LLVM: [[BFLOAD:%.*]] = load i16, ptr getelementptr inbounds nuw (i8, ptr {{.*}}, i64 2), align 2
@@ -191,10 +189,9 @@ void write16_1() {
191189
}
192190

193191
// CIR-LABEL: @_Z9write16_1v
194-
// CIR: [[CONST5:%.*]] = cir.const #cir.int<5> : !s32i
195-
// CIR: [[INT5:%.*]] = cir.cast integral [[CONST5]] : !s32i -> !u64i
192+
// CIR: [[CONST5:%.*]] = cir.const #cir.int<5> : !u64i
196193
// CIR: [[MEMBER:%.*]] = cir.get_member {{.*}}[0] {name = "f1"} : !cir.ptr<!rec_S2> -> !cir.ptr<!u16i>
197-
// CIR: cir.set_bitfield align(8) (#bfi_f1, [[MEMBER]] : !cir.ptr<!u16i>, [[INT5]] : !u64i) -> !u64i
194+
// CIR: cir.set_bitfield align(8) (#bfi_f1, [[MEMBER]] : !cir.ptr<!u16i>, [[CONST5]] : !u64i) -> !u64i
198195
// CIR: cir.return
199196

200197
// LLVM-LABEL: @_Z9write16_1v
@@ -211,10 +208,9 @@ void write16_2() {
211208
}
212209

213210
// CIR-LABEL: @_Z9write16_2v
214-
// CIR: [[CONST5:%.*]] = cir.const #cir.int<5> : !s32i
215-
// CIR: [[INT5:%.*]] = cir.cast integral [[CONST5]] : !s32i -> !u64i
211+
// CIR: [[CONST5:%.*]] = cir.const #cir.int<5> : !u64i
216212
// CIR: [[MEMBER:%.*]] = cir.get_member {{.*}}[1] {name = "f2"} : !cir.ptr<!rec_S2> -> !cir.ptr<!u16i>
217-
// CIR: cir.set_bitfield align(2) (#bfi_f2, [[MEMBER]] : !cir.ptr<!u16i>, {{.*}} : !u64i) -> !u64i
213+
// CIR: cir.set_bitfield align(2) (#bfi_f2, [[MEMBER]] : !cir.ptr<!u16i>, [[CONST5]] : !u64i) -> !u64i
218214
// CIR: cir.return
219215

220216
// LLVM-LABEL: @_Z9write16_2v
@@ -256,10 +252,9 @@ void write32_1() {
256252
}
257253

258254
// CIR-LABEL: @_Z9write32_1v
259-
// CIR: [[CONST5:%.*]] = cir.const #cir.int<5> : !s32i
260-
// CIR: [[INT5:%.*]] = cir.cast integral [[CONST5]] : !s32i -> !u64i
255+
// CIR: [[CONST5:%.*]] = cir.const #cir.int<5> : !u64i
261256
// CIR: [[MEMBER:%.*]] = cir.get_member {{.*}}[1] {name = "f3"} : !cir.ptr<!rec_S3> -> !cir.ptr<!u32i>
262-
// CIR: cir.set_bitfield align(4) (#bfi_f3_1, [[MEMBER]] : !cir.ptr<!u32i>, [[INT5]] : !u64i) -> !u64i
257+
// CIR: cir.set_bitfield align(4) (#bfi_f3_1, [[MEMBER]] : !cir.ptr<!u32i>, [[CONST5]] : !u64i) -> !u64i
263258
// CIR: cir.return
264259

265260
// LLVM-LABEL: @_Z9write32_1v

clang/test/CIR/CodeGen/struct.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,8 @@ void calling_function_with_default_values() {
344344
// CIR: %[[CONST_1:.*]] = cir.const #cir.int<1> : !s32i
345345
// CIR: cir.store{{.*}} %[[CONST_1]], %[[ELEM_0_PTR]] : !s32i, !cir.ptr<!s32i>
346346
// CIR: %[[ELEM_1_PTR:.*]] = cir.get_member %[[AGG_ADDR]][1] {name = "b"} : !cir.ptr<!rec_CompleteS> -> !cir.ptr<!s8i>
347-
// CIR: %[[CONST_2:.*]] = cir.const #cir.int<2> : !s32i
348-
// CIR: %[[CONST_2_I8:.*]] = cir.cast integral %[[CONST_2]] : !s32i -> !s8i
349-
// CIR: cir.store{{.*}} %[[CONST_2_I8]], %[[ELEM_1_PTR]] : !s8i, !cir.ptr<!s8i>
347+
// CIR: %[[CONST_2:.*]] = cir.const #cir.int<2> : !s8i
348+
// CIR: cir.store{{.*}} %[[CONST_2]], %[[ELEM_1_PTR]] : !s8i, !cir.ptr<!s8i>
350349
// CIR: %[[TMP_AGG:.*]] = cir.load{{.*}} %[[AGG_ADDR]] : !cir.ptr<!rec_CompleteS>, !rec_CompleteS
351350
// CIR: cir.call @_Z31function_arg_with_default_value9CompleteS(%[[TMP_AGG]]) : (!rec_CompleteS) -> ()
352351

clang/test/CIR/CodeGen/union.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,9 @@ void shouldGenerateUnionAccess(union U2 u) {
115115
// CIR: cir.func{{.*}} @shouldGenerateUnionAccess(%[[ARG:.*]]: !rec_U2
116116
// CIR-NEXT: %[[U:.*]] = cir.alloca !rec_U2, !cir.ptr<!rec_U2>, ["u", init] {alignment = 8 : i64}
117117
// CIR-NEXT: cir.store{{.*}} %[[ARG]], %[[U]] : !rec_U2, !cir.ptr<!rec_U2>
118-
// CIR-NEXT: %[[ZERO:.*]] = cir.const #cir.int<0> : !s32i
119-
// CIR-NEXT: %[[ZERO_CHAR:.*]] = cir.cast integral %[[ZERO]] : !s32i -> !s8i
118+
// CIR-NEXT: %[[ZERO:.*]] = cir.const #cir.int<0> : !s8i
120119
// CIR-NEXT: %[[B_PTR:.*]] = cir.get_member %[[U]][0] {name = "b"} : !cir.ptr<!rec_U2> -> !cir.ptr<!s8i>
121-
// CIR-NEXT: cir.store{{.*}} %[[ZERO_CHAR]], %[[B_PTR]] : !s8i, !cir.ptr<!s8i>
120+
// CIR-NEXT: cir.store{{.*}} %[[ZERO]], %[[B_PTR]] : !s8i, !cir.ptr<!s8i>
122121
// CIR-NEXT: %[[B_PTR2:.*]] = cir.get_member %[[U]][0] {name = "b"} : !cir.ptr<!rec_U2> -> !cir.ptr<!s8i>
123122
// CIR-NEXT: %[[B_VAL:.*]] = cir.load{{.*}} %[[B_PTR2]] : !cir.ptr<!s8i>, !s8i
124123
// CIR-NEXT: %[[ONE:.*]] = cir.const #cir.int<1> : !s32i
@@ -173,12 +172,11 @@ void f3(union U3 u) {
173172
// CIR: cir.func{{.*}} @f3(%[[ARG:.*]]: !rec_U3
174173
// CIR-NEXT: %[[U:.*]] = cir.alloca !rec_U3, !cir.ptr<!rec_U3>, ["u", init] {alignment = 1 : i64}
175174
// CIR-NEXT: cir.store{{.*}} %[[ARG]], %[[U]] : !rec_U3, !cir.ptr<!rec_U3>
176-
// CIR-NEXT: %[[ZERO:.*]] = cir.const #cir.int<0> : !s32i
177-
// CIR-NEXT: %[[ZERO_CHAR:.*]] = cir.cast integral %[[ZERO]] : !s32i -> !s8i
175+
// CIR-NEXT: %[[ZERO:.*]] = cir.const #cir.int<0> : !s8i
178176
// CIR-NEXT: %[[IDX:.*]] = cir.const #cir.int<2> : !s32i
179177
// CIR-NEXT: %[[C_PTR:.*]] = cir.get_member %[[U]][0] {name = "c"} : !cir.ptr<!rec_U3> -> !cir.ptr<!cir.array<!s8i x 5>>
180178
// CIR-NEXT: %[[ELEM_PTR:.*]] = cir.get_element %[[C_PTR]][%[[IDX]] : !s32i] : !cir.ptr<!cir.array<!s8i x 5>> -> !cir.ptr<!s8i>
181-
// CIR-NEXT: cir.store{{.*}} %[[ZERO_CHAR]], %[[ELEM_PTR]] : !s8i, !cir.ptr<!s8i>
179+
// CIR-NEXT: cir.store{{.*}} %[[ZERO]], %[[ELEM_PTR]] : !s8i, !cir.ptr<!s8i>
182180
// CIR-NEXT: cir.return
183181

184182
// LLVM: define{{.*}} void @f3(%union.U3 %[[ARG:.*]])
@@ -203,12 +201,11 @@ void f5(union U4 u) {
203201
// CIR: cir.func{{.*}} @f5(%[[ARG:.*]]: !rec_U4
204202
// CIR-NEXT: %[[U:.*]] = cir.alloca !rec_U4, !cir.ptr<!rec_U4>, ["u", init] {alignment = 4 : i64}
205203
// CIR-NEXT: cir.store{{.*}} %[[ARG]], %[[U]] : !rec_U4, !cir.ptr<!rec_U4>
206-
// CIR-NEXT: %[[CHAR_VAL:.*]] = cir.const #cir.int<65> : !s32i
207-
// CIR-NEXT: %[[CHAR_CAST:.*]] = cir.cast integral %[[CHAR_VAL]] : !s32i -> !s8i
204+
// CIR-NEXT: %[[CHAR_VAL:.*]] = cir.const #cir.int<65> : !s8i
208205
// CIR-NEXT: %[[IDX:.*]] = cir.const #cir.int<4> : !s32i
209206
// CIR-NEXT: %[[C_PTR:.*]] = cir.get_member %[[U]][0] {name = "c"} : !cir.ptr<!rec_U4> -> !cir.ptr<!cir.array<!s8i x 5>>
210207
// CIR-NEXT: %[[ELEM_PTR:.*]] = cir.get_element %[[C_PTR]][%[[IDX]] : !s32i] : !cir.ptr<!cir.array<!s8i x 5>> -> !cir.ptr<!s8i>
211-
// CIR-NEXT: cir.store{{.*}} %[[CHAR_CAST]], %[[ELEM_PTR]] : !s8i, !cir.ptr<!s8i>
208+
// CIR-NEXT: cir.store{{.*}} %[[CHAR_VAL]], %[[ELEM_PTR]] : !s8i, !cir.ptr<!s8i>
212209
// CIR-NEXT: cir.return
213210

214211
// LLVM: define{{.*}} void @f5(%union.U4 %[[ARG:.*]])

0 commit comments

Comments
 (0)