[clang] [CIR] Recognize constant aggregate initialization of auto vars (PR #166850)
Amr Hesham via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 6 13:50:10 PST 2025
================
@@ -312,23 +312,10 @@ void l5() {
// CIR: %[[BEGIN_ADDR:.*]] = cir.alloca {{.*}} ["__begin1", init]
// CIR: %[[END_ADDR:.*]] = cir.alloca {{.*}} ["__end1", init]
// CIR: %[[X_ADDR:.*]] = cir.alloca {{.*}} ["x", init]
-// CIR: %[[ARR_CAST:.*]] = cir.cast array_to_ptrdecay %[[ARR_ADDR]] : {{.*}}
-// CIR: %[[ONE:.*]] = cir.const #cir.int<1> : !s32i
-// CIR: cir.store{{.*}} %[[ONE]], %[[ARR_CAST]]
-// CIR: %[[OFFSET1:.*]] = cir.const #cir.int<1> : !s64i
-// CIR: %[[STRIDE:.*]] = cir.ptr_stride %[[ARR_CAST]], %[[OFFSET1]] : ({{.*}}, {{.*}})
-// CIR: %[[TWO:.*]] = cir.const #cir.int<2> : !s32i
-// CIR: cir.store{{.*}} %[[TWO]], %[[STRIDE]]
-// CIR: %[[OFFSET2:.*]] = cir.const #cir.int<2> : !s64i
-// CIR: %[[STRIDE2:.*]] = cir.ptr_stride %[[ARR_CAST]], %[[OFFSET2]] : ({{.*}}, {{.*}})
-// CIR: %[[THREE:.*]] = cir.const #cir.int<3> : !s32i
-// CIR: cir.store{{.*}} %[[THREE]], %[[STRIDE2]]
-// CIR: %[[OFFSET3:.*]] = cir.const #cir.int<3> : !s64i
-// CIR: %[[STRIDE3:.*]] = cir.ptr_stride %[[ARR_CAST]], %[[OFFSET3]] : ({{.*}}, {{.*}})
-// CIR: %[[FOUR:.*]] = cir.const #cir.int<4> : !s32i
-// CIR: cir.store{{.*}} %[[FOUR]], %[[STRIDE3]]
-// CIR: cir.store{{.*}} %[[ARR_ADDR]], %[[RANGE_ADDR]]
-// CIR: %[[RANGE_LOAD:.*]] = cir.load{{.*}} %[[RANGE_ADDR]]
+// CIR: %[[ARR_INIT:.*]] = cir.const #cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i]>
+// CIR: cir.store align(16) %[[ARR_INIT]], %[[ARR_ADDR]]
+// CIR: cir.store align(8) %[[ARR_ADDR]], %[[RANGE_ADDR]]
----------------
AmrDeveloper wrote:
```suggestion
// CIR: cir.store{{.*}} %[[ARR_INIT]], %[[ARR_ADDR]]
// CIR: cir.store{{.*}} %[[ARR_ADDR]], %[[RANGE_ADDR]]
```
https://github.com/llvm/llvm-project/pull/166850
More information about the cfe-commits
mailing list