1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -slp-vectorizer -S | FileCheck %s --check-prefix=DEFAULT 3; RUN: opt < %s -slp-schedule-budget=0 -slp-min-tree-size=0 -slp-threshold=-30 -slp-vectorizer -S | FileCheck %s --check-prefix=GATHER 4; RUN: opt < %s -slp-schedule-budget=0 -slp-threshold=-30 -slp-vectorizer -S | FileCheck %s --check-prefix=MAX-COST 5 6target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 7target triple = "aarch64--linux-gnu" 8 9@a = common global [80 x i8] zeroinitializer, align 16 10 11; DEFAULT-LABEL: @PR28330( 12; DEFAULT: %tmp17 = phi i32 [ %tmp34, %for.body ], [ 0, %entry ] 13; DEFAULT: %[[S0:.+]] = select <8 x i1> %1, <8 x i32> <i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720>, <8 x i32> <i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80> 14; DEFAULT: %[[R0:.+]] = shufflevector <8 x i32> %[[S0]], <8 x i32> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7, i32 undef, i32 undef, i32 undef, i32 undef> 15; DEFAULT: %[[R1:.+]] = add <8 x i32> %[[S0]], %[[R0]] 16; DEFAULT: %[[R2:.+]] = shufflevector <8 x i32> %[[R1]], <8 x i32> undef, <8 x i32> <i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> 17; DEFAULT: %[[R3:.+]] = add <8 x i32> %[[R1]], %[[R2]] 18; DEFAULT: %[[R4:.+]] = shufflevector <8 x i32> %[[R3]], <8 x i32> undef, <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> 19; DEFAULT: %[[R5:.+]] = add <8 x i32> %[[R3]], %[[R4]] 20; DEFAULT: %[[R6:.+]] = extractelement <8 x i32> %[[R5]], i32 0 21; DEFAULT: %tmp34 = add i32 %[[R6]], %tmp17 22; 23; GATHER-LABEL: @PR28330( 24; GATHER: %tmp17 = phi i32 [ %tmp34, %for.body ], [ 0, %entry ] 25; GATHER: %tmp19 = select i1 %tmp1, i32 -720, i32 -80 26; GATHER: %tmp21 = select i1 %tmp3, i32 -720, i32 -80 27; GATHER: %tmp23 = select i1 %tmp5, i32 -720, i32 -80 28; GATHER: %tmp25 = select i1 %tmp7, i32 -720, i32 -80 29; GATHER: %tmp27 = select i1 %tmp9, i32 -720, i32 -80 30; GATHER: %tmp29 = select i1 %tmp11, i32 -720, i32 -80 31; GATHER: %tmp31 = select i1 %tmp13, i32 -720, i32 -80 32; GATHER: %tmp33 = select i1 %tmp15, i32 -720, i32 -80 33; GATHER: %[[I0:.+]] = insertelement <8 x i32> undef, i32 %tmp19, i32 0 34; GATHER: %[[I1:.+]] = insertelement <8 x i32> %[[I0]], i32 %tmp21, i32 1 35; GATHER: %[[I2:.+]] = insertelement <8 x i32> %[[I1]], i32 %tmp23, i32 2 36; GATHER: %[[I3:.+]] = insertelement <8 x i32> %[[I2]], i32 %tmp25, i32 3 37; GATHER: %[[I4:.+]] = insertelement <8 x i32> %[[I3]], i32 %tmp27, i32 4 38; GATHER: %[[I5:.+]] = insertelement <8 x i32> %[[I4]], i32 %tmp29, i32 5 39; GATHER: %[[I6:.+]] = insertelement <8 x i32> %[[I5]], i32 %tmp31, i32 6 40; GATHER: %[[I7:.+]] = insertelement <8 x i32> %[[I6]], i32 %tmp33, i32 7 41; GATHER: %[[R0:.+]] = shufflevector <8 x i32> %[[I7]], <8 x i32> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7, i32 undef, i32 undef, i32 undef, i32 undef> 42; GATHER: %[[R1:.+]] = add <8 x i32> %[[I7]], %[[R0]] 43; GATHER: %[[R2:.+]] = shufflevector <8 x i32> %[[R1]], <8 x i32> undef, <8 x i32> <i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> 44; GATHER: %[[R3:.+]] = add <8 x i32> %[[R1]], %[[R2]] 45; GATHER: %[[R4:.+]] = shufflevector <8 x i32> %[[R3]], <8 x i32> undef, <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> 46; GATHER: %[[R5:.+]] = add <8 x i32> %[[R3]], %[[R4]] 47; GATHER: %[[R6:.+]] = extractelement <8 x i32> %[[R5]], i32 0 48; GATHER: %tmp34 = add i32 %[[R6]], %tmp17 49; 50; MAX-COST-LABEL: @PR28330( 51; MAX-COST-NOT: shufflevector 52 53define void @PR28330(i32 %n) { 54entry: 55 %tmp0 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 1), align 1 56 %tmp1 = icmp eq i8 %tmp0, 0 57 %tmp2 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 2), align 2 58 %tmp3 = icmp eq i8 %tmp2, 0 59 %tmp4 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 3), align 1 60 %tmp5 = icmp eq i8 %tmp4, 0 61 %tmp6 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 4), align 4 62 %tmp7 = icmp eq i8 %tmp6, 0 63 %tmp8 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 5), align 1 64 %tmp9 = icmp eq i8 %tmp8, 0 65 %tmp10 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 6), align 2 66 %tmp11 = icmp eq i8 %tmp10, 0 67 %tmp12 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 7), align 1 68 %tmp13 = icmp eq i8 %tmp12, 0 69 %tmp14 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 8), align 8 70 %tmp15 = icmp eq i8 %tmp14, 0 71 br label %for.body 72 73for.body: 74 %tmp17 = phi i32 [ %tmp34, %for.body ], [ 0, %entry ] 75 %tmp19 = select i1 %tmp1, i32 -720, i32 -80 76 %tmp20 = add i32 %tmp17, %tmp19 77 %tmp21 = select i1 %tmp3, i32 -720, i32 -80 78 %tmp22 = add i32 %tmp20, %tmp21 79 %tmp23 = select i1 %tmp5, i32 -720, i32 -80 80 %tmp24 = add i32 %tmp22, %tmp23 81 %tmp25 = select i1 %tmp7, i32 -720, i32 -80 82 %tmp26 = add i32 %tmp24, %tmp25 83 %tmp27 = select i1 %tmp9, i32 -720, i32 -80 84 %tmp28 = add i32 %tmp26, %tmp27 85 %tmp29 = select i1 %tmp11, i32 -720, i32 -80 86 %tmp30 = add i32 %tmp28, %tmp29 87 %tmp31 = select i1 %tmp13, i32 -720, i32 -80 88 %tmp32 = add i32 %tmp30, %tmp31 89 %tmp33 = select i1 %tmp15, i32 -720, i32 -80 90 %tmp34 = add i32 %tmp32, %tmp33 91 br label %for.body 92} 93 94define void @PR32038(i32 %n) { 95; DEFAULT-LABEL: @PR32038( 96; DEFAULT-NEXT: entry: 97; DEFAULT-NEXT: [[TMP0:%.*]] = load <8 x i8>, <8 x i8>* bitcast (i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 1) to <8 x i8>*), align 1 98; DEFAULT-NEXT: [[TMP1:%.*]] = icmp eq <8 x i8> [[TMP0]], zeroinitializer 99; DEFAULT-NEXT: br label [[FOR_BODY:%.*]] 100; DEFAULT: for.body: 101; DEFAULT-NEXT: [[TMP17:%.*]] = phi i32 [ [[TMP34:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ] 102; DEFAULT-NEXT: [[TMP2:%.*]] = select <8 x i1> [[TMP1]], <8 x i32> <i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720>, <8 x i32> <i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80> 103; DEFAULT-NEXT: [[TMP20:%.*]] = add i32 -5, undef 104; DEFAULT-NEXT: [[TMP22:%.*]] = add i32 [[TMP20]], undef 105; DEFAULT-NEXT: [[TMP24:%.*]] = add i32 [[TMP22]], undef 106; DEFAULT-NEXT: [[TMP26:%.*]] = add i32 [[TMP24]], undef 107; DEFAULT-NEXT: [[TMP28:%.*]] = add i32 [[TMP26]], undef 108; DEFAULT-NEXT: [[TMP30:%.*]] = add i32 [[TMP28]], undef 109; DEFAULT-NEXT: [[TMP32:%.*]] = add i32 [[TMP30]], undef 110; DEFAULT-NEXT: [[RDX_SHUF:%.*]] = shufflevector <8 x i32> [[TMP2]], <8 x i32> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7, i32 undef, i32 undef, i32 undef, i32 undef> 111; DEFAULT-NEXT: [[BIN_RDX:%.*]] = add <8 x i32> [[TMP2]], [[RDX_SHUF]] 112; DEFAULT-NEXT: [[RDX_SHUF1:%.*]] = shufflevector <8 x i32> [[BIN_RDX]], <8 x i32> undef, <8 x i32> <i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> 113; DEFAULT-NEXT: [[BIN_RDX2:%.*]] = add <8 x i32> [[BIN_RDX]], [[RDX_SHUF1]] 114; DEFAULT-NEXT: [[RDX_SHUF3:%.*]] = shufflevector <8 x i32> [[BIN_RDX2]], <8 x i32> undef, <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> 115; DEFAULT-NEXT: [[BIN_RDX4:%.*]] = add <8 x i32> [[BIN_RDX2]], [[RDX_SHUF3]] 116; DEFAULT-NEXT: [[TMP3:%.*]] = extractelement <8 x i32> [[BIN_RDX4]], i32 0 117; DEFAULT-NEXT: [[BIN_EXTRA:%.*]] = add i32 [[TMP3]], -5 118; DEFAULT-NEXT: [[TMP34]] = add i32 [[BIN_EXTRA]], [[TMP17]] 119; DEFAULT-NEXT: br label [[FOR_BODY]] 120; 121; GATHER-LABEL: @PR32038( 122; GATHER-NEXT: entry: 123; GATHER-NEXT: [[TMP0:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 1), align 1 124; GATHER-NEXT: [[TMP1:%.*]] = icmp eq i8 [[TMP0]], 0 125; GATHER-NEXT: [[TMP2:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 2), align 2 126; GATHER-NEXT: [[TMP3:%.*]] = icmp eq i8 [[TMP2]], 0 127; GATHER-NEXT: [[TMP4:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 3), align 1 128; GATHER-NEXT: [[TMP5:%.*]] = icmp eq i8 [[TMP4]], 0 129; GATHER-NEXT: [[TMP6:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 4), align 4 130; GATHER-NEXT: [[TMP7:%.*]] = icmp eq i8 [[TMP6]], 0 131; GATHER-NEXT: [[TMP8:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 5), align 1 132; GATHER-NEXT: [[TMP9:%.*]] = icmp eq i8 [[TMP8]], 0 133; GATHER-NEXT: [[TMP10:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 6), align 2 134; GATHER-NEXT: [[TMP11:%.*]] = icmp eq i8 [[TMP10]], 0 135; GATHER-NEXT: [[TMP12:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 7), align 1 136; GATHER-NEXT: [[TMP13:%.*]] = icmp eq i8 [[TMP12]], 0 137; GATHER-NEXT: [[TMP14:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 8), align 8 138; GATHER-NEXT: [[TMP15:%.*]] = icmp eq i8 [[TMP14]], 0 139; GATHER-NEXT: br label [[FOR_BODY:%.*]] 140; GATHER: for.body: 141; GATHER-NEXT: [[TMP17:%.*]] = phi i32 [ [[TMP34:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ] 142; GATHER-NEXT: [[TMP19:%.*]] = select i1 [[TMP1]], i32 -720, i32 -80 143; GATHER-NEXT: [[TMP20:%.*]] = add i32 -5, [[TMP19]] 144; GATHER-NEXT: [[TMP21:%.*]] = select i1 [[TMP3]], i32 -720, i32 -80 145; GATHER-NEXT: [[TMP22:%.*]] = add i32 [[TMP20]], [[TMP21]] 146; GATHER-NEXT: [[TMP23:%.*]] = select i1 [[TMP5]], i32 -720, i32 -80 147; GATHER-NEXT: [[TMP24:%.*]] = add i32 [[TMP22]], [[TMP23]] 148; GATHER-NEXT: [[TMP25:%.*]] = select i1 [[TMP7]], i32 -720, i32 -80 149; GATHER-NEXT: [[TMP26:%.*]] = add i32 [[TMP24]], [[TMP25]] 150; GATHER-NEXT: [[TMP27:%.*]] = select i1 [[TMP9]], i32 -720, i32 -80 151; GATHER-NEXT: [[TMP28:%.*]] = add i32 [[TMP26]], [[TMP27]] 152; GATHER-NEXT: [[TMP29:%.*]] = select i1 [[TMP11]], i32 -720, i32 -80 153; GATHER-NEXT: [[TMP30:%.*]] = add i32 [[TMP28]], [[TMP29]] 154; GATHER-NEXT: [[TMP31:%.*]] = select i1 [[TMP13]], i32 -720, i32 -80 155; GATHER-NEXT: [[TMP32:%.*]] = add i32 [[TMP30]], [[TMP31]] 156; GATHER-NEXT: [[TMP33:%.*]] = select i1 [[TMP15]], i32 -720, i32 -80 157; GATHER-NEXT: [[TMP0:%.*]] = insertelement <8 x i32> undef, i32 [[TMP19]], i32 0 158; GATHER-NEXT: [[TMP1:%.*]] = insertelement <8 x i32> [[TMP0]], i32 [[TMP21]], i32 1 159; GATHER-NEXT: [[TMP2:%.*]] = insertelement <8 x i32> [[TMP1]], i32 [[TMP23]], i32 2 160; GATHER-NEXT: [[TMP3:%.*]] = insertelement <8 x i32> [[TMP2]], i32 [[TMP25]], i32 3 161; GATHER-NEXT: [[TMP4:%.*]] = insertelement <8 x i32> [[TMP3]], i32 [[TMP27]], i32 4 162; GATHER-NEXT: [[TMP5:%.*]] = insertelement <8 x i32> [[TMP4]], i32 [[TMP29]], i32 5 163; GATHER-NEXT: [[TMP6:%.*]] = insertelement <8 x i32> [[TMP5]], i32 [[TMP31]], i32 6 164; GATHER-NEXT: [[TMP7:%.*]] = insertelement <8 x i32> [[TMP6]], i32 [[TMP33]], i32 7 165; GATHER-NEXT: [[RDX_SHUF:%.*]] = shufflevector <8 x i32> [[TMP7]], <8 x i32> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7, i32 undef, i32 undef, i32 undef, i32 undef> 166; GATHER-NEXT: [[BIN_RDX:%.*]] = add <8 x i32> [[TMP7]], [[RDX_SHUF]] 167; GATHER-NEXT: [[RDX_SHUF1:%.*]] = shufflevector <8 x i32> [[BIN_RDX]], <8 x i32> undef, <8 x i32> <i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> 168; GATHER-NEXT: [[BIN_RDX2:%.*]] = add <8 x i32> [[BIN_RDX]], [[RDX_SHUF1]] 169; GATHER-NEXT: [[RDX_SHUF3:%.*]] = shufflevector <8 x i32> [[BIN_RDX2]], <8 x i32> undef, <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> 170; GATHER-NEXT: [[BIN_RDX4:%.*]] = add <8 x i32> [[BIN_RDX2]], [[RDX_SHUF3]] 171; GATHER-NEXT: [[TMP8:%.*]] = extractelement <8 x i32> [[BIN_RDX4]], i32 0 172; GATHER-NEXT: [[BIN_EXTRA:%.*]] = add i32 [[TMP8]], -5 173; GATHER-NEXT: [[TMP34]] = add i32 [[BIN_EXTRA]], [[TMP17]] 174; GATHER-NEXT: br label [[FOR_BODY]] 175; 176; MAX-COST-LABEL: @PR32038( 177entry: 178 %tmp0 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 1), align 1 179 %tmp1 = icmp eq i8 %tmp0, 0 180 %tmp2 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 2), align 2 181 %tmp3 = icmp eq i8 %tmp2, 0 182 %tmp4 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 3), align 1 183 %tmp5 = icmp eq i8 %tmp4, 0 184 %tmp6 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 4), align 4 185 %tmp7 = icmp eq i8 %tmp6, 0 186 %tmp8 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 5), align 1 187 %tmp9 = icmp eq i8 %tmp8, 0 188 %tmp10 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 6), align 2 189 %tmp11 = icmp eq i8 %tmp10, 0 190 %tmp12 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 7), align 1 191 %tmp13 = icmp eq i8 %tmp12, 0 192 %tmp14 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 8), align 8 193 %tmp15 = icmp eq i8 %tmp14, 0 194 br label %for.body 195 196for.body: 197 %tmp17 = phi i32 [ %tmp34, %for.body ], [ 0, %entry ] 198 %tmp19 = select i1 %tmp1, i32 -720, i32 -80 199 %tmp20 = add i32 -5, %tmp19 200 %tmp21 = select i1 %tmp3, i32 -720, i32 -80 201 %tmp22 = add i32 %tmp20, %tmp21 202 %tmp23 = select i1 %tmp5, i32 -720, i32 -80 203 %tmp24 = add i32 %tmp22, %tmp23 204 %tmp25 = select i1 %tmp7, i32 -720, i32 -80 205 %tmp26 = add i32 %tmp24, %tmp25 206 %tmp27 = select i1 %tmp9, i32 -720, i32 -80 207 %tmp28 = add i32 %tmp26, %tmp27 208 %tmp29 = select i1 %tmp11, i32 -720, i32 -80 209 %tmp30 = add i32 %tmp28, %tmp29 210 %tmp31 = select i1 %tmp13, i32 -720, i32 -80 211 %tmp32 = add i32 %tmp30, %tmp31 212 %tmp33 = select i1 %tmp15, i32 -720, i32 -80 213 %tmp34 = add i32 %tmp32, %tmp33 214 br label %for.body 215} 216