1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -slp-vectorizer -S -mtriple=x86_64-unknown-linux -march=core-avx2 | FileCheck %s 3; RUN: opt < %s -slp-vectorizer -S -mtriple=x86_64-unknown-linux -march=core-avx2 -slp-threshold=-1 -slp-vectorize-hor-store | FileCheck %s --check-prefix=THRESH1 4; RUN: opt < %s -slp-vectorizer -S -mtriple=x86_64-unknown-linux -march=core-avx2 -slp-threshold=-2 -slp-vectorize-hor-store | FileCheck %s --check-prefix=THRESH2 5 6@a = global float 0.000000e+00, align 4 7 8define float @f(<2 x float> %x) { 9; CHECK-LABEL: @f( 10; CHECK-NEXT: [[TMP1:%.*]] = fmul <2 x float> [[X:%.*]], [[X]] 11; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x float> [[TMP1]], i32 0 12; CHECK-NEXT: [[TMP3:%.*]] = extractelement <2 x float> [[TMP1]], i32 1 13; CHECK-NEXT: [[ADD:%.*]] = fadd float [[TMP2]], [[TMP3]] 14; CHECK-NEXT: ret float [[ADD]] 15; 16 %x0 = extractelement <2 x float> %x, i32 0 17 %x1 = extractelement <2 x float> %x, i32 1 18 %x0x0 = fmul float %x0, %x0 19 %x1x1 = fmul float %x1, %x1 20 %add = fadd float %x0x0, %x1x1 21 ret float %add 22} 23 24define float @f_used_out_of_tree(<2 x float> %x) { 25; THRESH2-LABEL: @f_used_out_of_tree( 26; THRESH2-NEXT: [[TMP1:%.*]] = extractelement <2 x float> [[X:%.*]], i32 0 27; THRESH2-NEXT: [[TMP2:%.*]] = fmul <2 x float> [[X]], [[X]] 28; THRESH2-NEXT: [[TMP3:%.*]] = extractelement <2 x float> [[TMP2]], i32 0 29; THRESH2-NEXT: [[TMP4:%.*]] = extractelement <2 x float> [[TMP2]], i32 1 30; THRESH2-NEXT: [[ADD:%.*]] = fadd float [[TMP3]], [[TMP4]] 31; THRESH2-NEXT: store float [[ADD]], float* @a 32; THRESH2-NEXT: ret float [[TMP1]] 33; 34 %x0 = extractelement <2 x float> %x, i32 0 35 %x1 = extractelement <2 x float> %x, i32 1 36 %x0x0 = fmul float %x0, %x0 37 %x1x1 = fmul float %x1, %x1 38 %add = fadd float %x0x0, %x1x1 39 store float %add, float* @a 40 ret float %x0 41} 42 43define float @f_used_twice_in_tree(<2 x float> %x) { 44; THRESH1-LABEL: @f_used_twice_in_tree( 45; THRESH1-NEXT: [[TMP1:%.*]] = extractelement <2 x float> [[X:%.*]], i32 1 46; THRESH1-NEXT: [[TMP2:%.*]] = insertelement <2 x float> undef, float [[TMP1]], i32 0 47; THRESH1-NEXT: [[TMP3:%.*]] = insertelement <2 x float> [[TMP2]], float [[TMP1]], i32 1 48; THRESH1-NEXT: [[TMP4:%.*]] = fmul <2 x float> [[X]], [[TMP3]] 49; THRESH1-NEXT: [[TMP5:%.*]] = extractelement <2 x float> [[TMP4]], i32 0 50; THRESH1-NEXT: [[TMP6:%.*]] = extractelement <2 x float> [[TMP4]], i32 1 51; THRESH1-NEXT: [[ADD:%.*]] = fadd float [[TMP5]], [[TMP6]] 52; THRESH1-NEXT: ret float [[ADD]] 53; 54 %x0 = extractelement <2 x float> %x, i32 0 55 %x1 = extractelement <2 x float> %x, i32 1 56 %x0x0 = fmul float %x0, %x1 57 %x1x1 = fmul float %x1, %x1 58 %add = fadd float %x0x0, %x1x1 59 ret float %add 60} 61 62