• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -instcombine -S -o - %s | FileCheck %s
2; Tests that we don't crash upon encountering a vector GEP
3
4target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5target triple = "x86_64-unknown-linux-gnu"
6
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] }
11
12; Function Attrs: sspreq
13define <8 x i64*> @"julia_axpy!_65480"(%Dual* %arg1, <8 x i64> %arg2) {
14top:
15; CHECK: %VectorGep14 = getelementptr inbounds %Dual, %Dual* %arg1, <8 x i64> %arg2, i32 1, i32 0, i64 0, i32 1, i32 0, i64 0
16  %VectorGep14 = getelementptr inbounds %Dual, %Dual* %arg1, <8 x i64> %arg2, i32 1, i32 0, i64 0, i32 1, i32 0, i64 0
17  %0 = bitcast <8 x double*> %VectorGep14 to <8 x i64*>
18  ret <8 x i64*> %0
19}
20
21%struct.A = type { i32, %struct.B* }
22%struct.B = type { i64, %struct.C* }
23%struct.C = type { i64 }
24
25@G = internal global [65 x %struct.A] zeroinitializer, align 16
26; CHECK-LABEL: @test
27; CHECK: ret <16 x i32*> getelementptr ([65 x %struct.A], [65 x %struct.A]* @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)
28define <16 x i32*> @test() {
29vector.body:
30  %VectorGep = getelementptr [65 x %struct.A], [65 x %struct.A]* @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 i32*> %VectorGep
32}
33
34; CHECK-LABEL: @test2
35; CHECK: ret <16 x i32*> getelementptr ([65 x %struct.A], [65 x %struct.A]* @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,
36define <16 x i32*> @test2() {
37vector.body:
38  %VectorGep = getelementptr [65 x %struct.A], [65 x %struct.A]* @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 i32*> %VectorGep
40}
41
42@g = external global i8, align 1
43
44define <2 x i8*> @constant_zero_index() {
45; CHECK-LABEL: @constant_zero_index(
46; CHECK-NEXT:    ret <2 x i8*> <i8* @g, i8* @g>
47;
48  %gep = getelementptr i8, i8* @g, <2 x i64> zeroinitializer
49  ret <2 x i8*> %gep
50}
51
52define <2 x i8*> @constant_undef_index() {
53; CHECK-LABEL: @constant_undef_index(
54; CHECK-NEXT:    ret <2 x i8*> <i8* @g, i8* @g>
55;
56  %gep = getelementptr i8, i8* @g, <2 x i64> undef
57  ret <2 x i8*> %gep
58}
59
60define <2 x i8*> @constant_inbounds() {
61; CHECK-LABEL: @constant_inbounds(
62; CHECK-NEXT:    ret <2 x i8*> getelementptr inbounds (i8, i8* @g, <2 x i64> <i64 1, i64 1>)
63;
64  %gep = getelementptr i8, i8* @g, <2 x i64> <i64 1, i64 1>
65  ret <2 x i8*> %gep
66}
67