1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -passes=consthoist -consthoist-gep -S -o - %s | FileCheck %s
4 target triple = "aarch64"
6 %0 = type { %1, %2, [9 x i16], %6, %7 }
7 %1 = type { i32, i32, i32, i32, i32, i32, i16, i16, i8, i8, i16, i32, i32, i16, i8, i8 }
8 %2 = type { i32, %3, i8, i8, i8, i8, i32, %4, %5, [16 x i8], i16, i16, i8, i8, i8, i8, i32, i32, i32 }
9 %3 = type { i16, i8, i8 }
10 %4 = type { i16, i8, i8 }
11 %5 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }
13 %7 = type { [5 x i32], [3 x i32], [6 x i32], [3 x i32], [2 x i32], [4 x i32], [3 x i32], [2 x i32], [4 x i32], [5 x i32], [3 x i32], [6 x i32], [1 x i32], i32, i32, i32, i32, i32, i32 }
15 @global = external dso_local local_unnamed_addr global %0, align 4
17 ; Check that constant GEP expressions are rewritten to one-dimensional
18 ; (single-index) GEPs, whose base poiner is a multi-dimensional GEP.
19 define dso_local void @zot() {
20 ; CHECK-LABEL: define dso_local void @zot() {
22 ; CHECK-NEXT: [[CONST:%.*]] = bitcast ptr getelementptr inbounds ([[TMP0:%.*]], ptr @global, i32 0, i32 4, i32 0, i32 0) to ptr
23 ; CHECK-NEXT: store i32 undef, ptr [[CONST]], align 4
24 ; CHECK-NEXT: [[MAT_GEP:%.*]] = getelementptr i8, ptr [[CONST]], i32 4
25 ; CHECK-NEXT: [[MAT_BITCAST:%.*]] = bitcast ptr [[MAT_GEP]] to ptr
26 ; CHECK-NEXT: store i32 undef, ptr [[MAT_BITCAST]], align 4
27 ; CHECK-NEXT: [[MAT_GEP1:%.*]] = getelementptr i8, ptr [[CONST]], i32 160
28 ; CHECK-NEXT: [[MAT_BITCAST2:%.*]] = bitcast ptr [[MAT_GEP1]] to ptr
29 ; CHECK-NEXT: store i32 undef, ptr [[MAT_BITCAST2]], align 4
30 ; CHECK-NEXT: [[MAT_GEP3:%.*]] = getelementptr i8, ptr [[CONST]], i32 164
31 ; CHECK-NEXT: [[MAT_BITCAST4:%.*]] = bitcast ptr [[MAT_GEP3]] to ptr
32 ; CHECK-NEXT: store i32 undef, ptr [[MAT_BITCAST4]], align 4
33 ; CHECK-NEXT: ret void
36 store i32 undef, ptr getelementptr inbounds (%0, ptr @global, i32 0, i32 4, i32 0, i32 0), align 4
37 store i32 undef, ptr getelementptr inbounds (%0, ptr @global, i32 0, i32 4, i32 0, i32 1), align 4
38 store i32 undef, ptr getelementptr inbounds (%0, ptr @global, i32 0, i32 4, i32 11, i32 0), align 4
39 store i32 undef, ptr getelementptr inbounds (%0, ptr @global, i32 0, i32 4, i32 11, i32 1), align 4