1; RUN: llc < %s -mtriple=i686-linux -mcpu=corei7-avx | FileCheck %s 2; RUN: opt -instsimplify -disable-output < %s 3 4;CHECK-LABEL: AGEP0: 5define <4 x i32*> @AGEP0(i32* %ptr) nounwind { 6entry: 7;CHECK-LABEL: AGEP0 8;CHECK: vbroadcast 9;CHECK-NEXT: vpaddd 10;CHECK-NEXT: ret 11 %vecinit.i = insertelement <4 x i32*> undef, i32* %ptr, i32 0 12 %vecinit2.i = insertelement <4 x i32*> %vecinit.i, i32* %ptr, i32 1 13 %vecinit4.i = insertelement <4 x i32*> %vecinit2.i, i32* %ptr, i32 2 14 %vecinit6.i = insertelement <4 x i32*> %vecinit4.i, i32* %ptr, i32 3 15 %A2 = getelementptr i32, <4 x i32*> %vecinit6.i, <4 x i32> <i32 1, i32 2, i32 3, i32 4> 16 %A3 = getelementptr i32, <4 x i32*> %A2, <4 x i32> <i32 10, i32 14, i32 19, i32 233> 17 ret <4 x i32*> %A3 18} 19 20;CHECK-LABEL: AGEP1: 21define i32 @AGEP1(<4 x i32*> %param) nounwind { 22entry: 23;CHECK-LABEL: AGEP1 24;CHECK: vpaddd 25;CHECK-NEXT: vpextrd 26;CHECK-NEXT: movl 27 %A2 = getelementptr i32, <4 x i32*> %param, <4 x i32> <i32 1, i32 2, i32 3, i32 4> 28 %k = extractelement <4 x i32*> %A2, i32 3 29 %v = load i32, i32* %k 30 ret i32 %v 31;CHECK: ret 32} 33 34;CHECK-LABEL: AGEP2: 35define i32 @AGEP2(<4 x i32*> %param, <4 x i32> %off) nounwind { 36entry: 37;CHECK-LABEL: AGEP2 38;CHECK: vpslld $2 39;CHECK-NEXT: vpadd 40 %A2 = getelementptr i32, <4 x i32*> %param, <4 x i32> %off 41 %k = extractelement <4 x i32*> %A2, i32 3 42 %v = load i32, i32* %k 43 ret i32 %v 44;CHECK: ret 45} 46 47;CHECK-LABEL: AGEP3: 48define <4 x i32*> @AGEP3(<4 x i32*> %param, <4 x i32> %off) nounwind { 49entry: 50;CHECK-LABEL: AGEP3 51;CHECK: vpslld $2 52;CHECK-NEXT: vpadd 53 %A2 = getelementptr i32, <4 x i32*> %param, <4 x i32> %off 54 %v = alloca i32 55 %k = insertelement <4 x i32*> %A2, i32* %v, i32 3 56 ret <4 x i32*> %k 57;CHECK: ret 58} 59 60;CHECK-LABEL: AGEP4: 61define <4 x i16*> @AGEP4(<4 x i16*> %param, <4 x i32> %off) nounwind { 62entry: 63;CHECK-LABEL: AGEP4 64; Multiply offset by two (add it to itself). 65;CHECK: vpadd 66; add the base to the offset 67;CHECK-NEXT: vpadd 68 %A = getelementptr i16, <4 x i16*> %param, <4 x i32> %off 69 ret <4 x i16*> %A 70;CHECK: ret 71} 72 73;CHECK-LABEL: AGEP5: 74define <4 x i8*> @AGEP5(<4 x i8*> %param, <4 x i8> %off) nounwind { 75entry: 76;CHECK-LABEL: AGEP5 77;CHECK: vpaddd 78 %A = getelementptr i8, <4 x i8*> %param, <4 x i8> %off 79 ret <4 x i8*> %A 80;CHECK: ret 81} 82 83 84; The size of each element is 1 byte. No need to multiply by element size. 85;CHECK-LABEL: AGEP6: 86define <4 x i8*> @AGEP6(<4 x i8*> %param, <4 x i32> %off) nounwind { 87entry: 88;CHECK-LABEL: AGEP6 89;CHECK-NOT: pslld 90 %A = getelementptr i8, <4 x i8*> %param, <4 x i32> %off 91 ret <4 x i8*> %A 92;CHECK: ret 93} 94 95;CHECK-LABEL: AGEP7: 96define <4 x i8*> @AGEP7(<4 x i8*> %param, i32 %off) nounwind { 97entry: 98;CHECK: vbroadcastss 99;CHECK: vpadd 100 %A = getelementptr i8, <4 x i8*> %param, i32 %off 101 ret <4 x i8*> %A 102;CHECK: ret 103} 104 105;CHECK-LABEL: AGEP8: 106define <4 x i16*> @AGEP8(i16* %param, <4 x i32> %off) nounwind { 107entry: 108; Multiply offset by two (add it to itself). 109;CHECK: vpadd 110; add the base to the offset 111;CHECK: vbroadcastss 112;CHECK-NEXT: vpadd 113 %A = getelementptr i16, i16* %param, <4 x i32> %off 114 ret <4 x i16*> %A 115;CHECK: ret 116} 117 118;CHECK-LABEL: AGEP9: 119define <64 x i16*> @AGEP9(i16* %param, <64 x i32> %off) nounwind { 120entry: 121;CHECK: vbroadcastss 122 %A = getelementptr i16, i16* %param, <64 x i32> %off 123 ret <64 x i16*> %A 124;CHECK: ret 125} 126