1 ; RUN: opt -passes=instcombine -S -o - %s | FileCheck %s
2 ; Tests that we don't crash upon encountering a vector GEP
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 %Dual = type { %Dual.72, %Partials.73 }
8 %Dual.72 = type { double, %Partials }
9 %Partials = type { [2 x double] }
10 %Partials.73 = type { [2 x %Dual.72] }
12 ; Function Attrs: sspreq
13 define <8 x ptr> @"julia_axpy!_65480"(ptr %arg1, <8 x i64> %arg2) {
15 ; CHECK: %VectorGep14 = getelementptr inbounds %Dual, ptr %arg1, <8 x i64> %arg2, i32 1, i32 0, i64 0, i32 1, i32 0, i64 0
16 %VectorGep14 = getelementptr inbounds %Dual, ptr %arg1, <8 x i64> %arg2, i32 1, i32 0, i64 0, i32 1, i32 0, i64 0
17 %0 = bitcast <8 x ptr> %VectorGep14 to <8 x ptr>
21 %struct.A = type { i32, ptr }
22 %struct.B = type { i64, ptr }
23 %struct.C = type { i64 }
25 @G = internal global [65 x %struct.A] zeroinitializer, align 16
27 ; CHECK: ret <16 x ptr> getelementptr ([65 x %struct.A], ptr @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, i32 0)
28 define <16 x ptr> @test() {
30 %VectorGep = getelementptr [65 x %struct.A], ptr @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, <16 x i32> zeroinitializer
31 ret <16 x ptr> %VectorGep
35 ; CHECK: ret <16 x ptr> getelementptr ([65 x %struct.A], ptr @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9,
36 define <16 x ptr> @test2() {
38 %VectorGep = getelementptr [65 x %struct.A], ptr @G, <16 x i32> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, <16 x i32> zeroinitializer
39 ret <16 x ptr> %VectorGep
42 @g = external global i8, align 1
44 define <2 x ptr> @constant_zero_index() {
45 ; CHECK-LABEL: @constant_zero_index(
46 ; CHECK-NEXT: ret <2 x ptr> <ptr @g, ptr @g>
48 %gep = getelementptr i8, ptr @g, <2 x i64> zeroinitializer
52 define <2 x ptr> @constant_undef_index() {
53 ; CHECK-LABEL: @constant_undef_index(
54 ; CHECK-NEXT: ret <2 x ptr> <ptr @g, ptr @g>
56 %gep = getelementptr i8, ptr @g, <2 x i64> undef
60 define <2 x ptr> @constant_inbounds() {
61 ; CHECK-LABEL: @constant_inbounds(
62 ; CHECK-NEXT: ret <2 x ptr> getelementptr inbounds (i8, ptr @g, <2 x i64> <i64 1, i64 1>)
64 %gep = getelementptr i8, ptr @g, <2 x i64> <i64 1, i64 1>