1; RUN: opt -S -instsimplify < %s | FileCheck %s 2 3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 4 5declare void @helper(<2 x i8*>) 6define void @test(<2 x i8*> %a) { 7 %A = getelementptr i8, <2 x i8*> %a, <2 x i32> <i32 0, i32 0> 8 call void @helper(<2 x i8*> %A) 9 ret void 10} 11 12define <4 x i8*> @test1(<4 x i8*> %a) { 13 %gep = getelementptr i8, <4 x i8*> %a, <4 x i32> zeroinitializer 14 ret <4 x i8*> %gep 15 16; CHECK-LABEL: @test1 17; CHECK-NEXT: ret <4 x i8*> %a 18} 19 20define <4 x i8*> @test2(<4 x i8*> %a) { 21 %gep = getelementptr i8, <4 x i8*> %a 22 ret <4 x i8*> %gep 23 24; CHECK-LABEL: @test2 25; CHECK-NEXT: ret <4 x i8*> %a 26} 27 28%struct = type { double, float } 29 30define <4 x float*> @test3() { 31 %gep = getelementptr %struct, <4 x %struct*> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> <i32 1, i32 1, i32 1, i32 1> 32 ret <4 x float*> %gep 33 34; CHECK-LABEL: @test3 35; CHECK-NEXT: ret <4 x float*> undef 36} 37 38%struct.empty = type { } 39 40define <4 x %struct.empty*> @test4(<4 x %struct.empty*> %a) { 41 %gep = getelementptr %struct.empty, <4 x %struct.empty*> %a, <4 x i32> <i32 1, i32 1, i32 1, i32 1> 42 ret <4 x %struct.empty*> %gep 43 44; CHECK-LABEL: @test4 45; CHECK-NEXT: ret <4 x %struct.empty*> %a 46} 47 48define <4 x i8*> @test5() { 49 %c = inttoptr <4 x i64> <i64 1, i64 2, i64 3, i64 4> to <4 x i8*> 50 %gep = getelementptr i8, <4 x i8*> %c, <4 x i32> <i32 1, i32 1, i32 1, i32 1> 51 ret <4 x i8*> %gep 52 53; CHECK-LABEL: @test5 54; CHECK-NEXT: ret <4 x i8*> getelementptr (i8, <4 x i8*> <i8* inttoptr (i64 1 to i8*), i8* inttoptr (i64 2 to i8*), i8* inttoptr (i64 3 to i8*), i8* inttoptr (i64 4 to i8*)>, <4 x i32> <i32 1, i32 1, i32 1, i32 1>) 55} 56 57@v = global [24 x [42 x [3 x i32]]] zeroinitializer, align 16 58 59define <16 x i32*> @test6() { 60; CHECK-LABEL: @test6 61; CHECK-NEXT: ret <16 x i32*> getelementptr ([24 x [42 x [3 x i32]]], [24 x [42 x [3 x i32]]]* @v, <16 x i64> zeroinitializer, <16 x i64> zeroinitializer, <16 x i64> <i64 0, 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>, <16 x i64> zeroinitializer) 62 %VectorGep = getelementptr [24 x [42 x [3 x i32]]], [24 x [42 x [3 x i32]]]* @v, i64 0, i64 0, <16 x i64> <i64 0, 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 0 63 ret <16 x i32*> %VectorGep 64}