105 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -passes=slp-vectorizer < %s -S -mtriple="x86_64-grtev3-linux-gnu" -mcpu=corei7-avx | FileCheck %s3 4target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"5 6; We used to crash on this example because we were building a constant7; expression during vectorization and the vectorizer expects instructions8; as elements of the vectorized tree.9; PR1962110 11define void @test(i1 %arg) {12; CHECK-LABEL: @test(13; CHECK-NEXT: bb279:14; CHECK-NEXT: br label [[BB283:%.*]]15; CHECK: bb283:16; CHECK-NEXT: [[TMP0:%.*]] = phi <2 x float> [ zeroinitializer, [[BB279:%.*]] ], [ [[TMP11:%.*]], [[EXIT:%.*]] ]17; CHECK-NEXT: [[TMP1:%.*]] = phi <2 x float> [ zeroinitializer, [[BB279]] ], [ zeroinitializer, [[EXIT]] ]18; CHECK-NEXT: br label [[BB284:%.*]]19; CHECK: bb284:20; CHECK-NEXT: [[TMP2:%.*]] = fpext <2 x float> [[TMP0]] to <2 x double>21; CHECK-NEXT: [[TMP3:%.*]] = fsub <2 x double> [[TMP2]], zeroinitializer22; CHECK-NEXT: [[TMP4:%.*]] = fsub <2 x double> [[TMP3]], zeroinitializer23; CHECK-NEXT: br label [[BB21_I:%.*]]24; CHECK: bb21.i:25; CHECK-NEXT: br i1 [[ARG:%.*]], label [[BB22_I:%.*]], label [[EXIT]]26; CHECK: bb22.i:27; CHECK-NEXT: [[TMP5:%.*]] = fadd <2 x double> zeroinitializer, [[TMP4]]28; CHECK-NEXT: br label [[BB32_I:%.*]]29; CHECK: bb32.i:30; CHECK-NEXT: [[TMP6:%.*]] = phi <2 x double> [ [[TMP5]], [[BB22_I]] ], [ zeroinitializer, [[BB32_I]] ]31; CHECK-NEXT: br i1 [[ARG]], label [[BB32_I]], label [[BB21_I]]32; CHECK: exit:33; CHECK-NEXT: [[TMP7:%.*]] = fpext <2 x float> [[TMP1]] to <2 x double>34; CHECK-NEXT: [[TMP8:%.*]] = fmul <2 x double> [[TMP7]], zeroinitializer35; CHECK-NEXT: [[TMP9:%.*]] = fadd <2 x double> zeroinitializer, [[TMP8]]36; CHECK-NEXT: [[TMP10:%.*]] = fadd <2 x double> [[TMP9]], zeroinitializer37; CHECK-NEXT: [[TMP11]] = fptrunc <2 x double> [[TMP10]] to <2 x float>38; CHECK-NEXT: br label [[BB283]]39;40bb279:41 br label %bb28342 43bb283:44 %Av.sroa.8.0 = phi float [ zeroinitializer, %bb279 ], [ %tmp315, %exit ]45 %Av.sroa.5.0 = phi float [ zeroinitializer, %bb279 ], [ %tmp319, %exit ]46 %Av.sroa.3.0 = phi float [ zeroinitializer, %bb279 ], [ %tmp307, %exit ]47 %Av.sroa.0.0 = phi float [ zeroinitializer, %bb279 ], [ %tmp317, %exit ]48 br label %bb28449 50bb284:51 %tmp7.i = fpext float %Av.sroa.3.0 to double52 %tmp8.i = fsub double %tmp7.i, zeroinitializer53 %tmp9.i = fsub double %tmp8.i, zeroinitializer54 %tmp17.i = fpext float %Av.sroa.8.0 to double55 %tmp19.i = fsub double %tmp17.i, zeroinitializer56 %tmp20.i = fsub double %tmp19.i, zeroinitializer57 br label %bb21.i58 59bb21.i:60 br i1 %arg, label %bb22.i, label %exit61 62bb22.i:63 %tmp24.i = fadd double zeroinitializer, %tmp9.i64 %tmp26.i = fadd double zeroinitializer, %tmp20.i65 br label %bb32.i66 67bb32.i:68 %xs.0.i = phi double [ %tmp24.i, %bb22.i ], [ 0.000000e+00, %bb32.i ]69 %ys.0.i = phi double [ %tmp26.i, %bb22.i ], [ 0.000000e+00, %bb32.i ]70 br i1 %arg, label %bb32.i, label %bb21.i71 72exit:73 %tmp303 = fpext float %Av.sroa.0.0 to double74 %tmp304 = fmul double %tmp303, zeroinitializer75 %tmp305 = fadd double zeroinitializer, %tmp30476 %tmp306 = fadd double %tmp305, zeroinitializer77 %tmp307 = fptrunc double %tmp306 to float78 %tmp311 = fpext float %Av.sroa.5.0 to double79 %tmp312 = fmul double %tmp311, 0.000000e+0080 %tmp313 = fadd double zeroinitializer, %tmp31281 %tmp314 = fadd double %tmp313, zeroinitializer82 %tmp315 = fptrunc double %tmp314 to float83 %tmp317 = fptrunc double zeroinitializer to float84 %tmp319 = fptrunc double zeroinitializer to float85 br label %bb28386}87 88; Make sure that we probably handle constant folded vectorized trees. The89; vectorizer starts at the type (%t2, %t3) and wil constant fold the tree.90; The code that handles insertelement instructions must handle this.91define <4 x double> @constant_folding() {92; CHECK-LABEL: @constant_folding(93; CHECK-NEXT: entry:94; CHECK-NEXT: ret <4 x double> <double 2.000000e+00, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00>95;96entry:97 %t0 = fadd double 1.000000e+00 , 0.000000e+0098 %t1 = fadd double 1.000000e+00 , 1.000000e+0099 %t2 = fmul double %t0, 1.000000e+00100 %i1 = insertelement <4 x double> zeroinitializer, double %t2, i32 1101 %t3 = fmul double %t1, 1.000000e+00102 %i2 = insertelement <4 x double> %i1, double %t3, i32 0103 ret <4 x double> %i2104}105