brintos

brintos / llvm-project-archived public Read only

0
0
Text · 12.3 KiB · 8ab7f31 Raw
223 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -passes='instcombine' -S %s | FileCheck %s3 4define <4 x i8> @splat_binop_non_splat_x(<4 x i8> %x, <4 x i8> %y) {5; CHECK-LABEL: @splat_binop_non_splat_x(6; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> poison, <4 x i32> <i32 0, i32 2, i32 poison, i32 poison>7; CHECK-NEXT:    call void @use(<4 x i8> [[XSPLAT]])8; CHECK-NEXT:    [[B:%.*]] = add <4 x i8> [[XSPLAT]], [[Y:%.*]]9; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x i8> [[B]], <4 x i8> poison, <4 x i32> zeroinitializer10; CHECK-NEXT:    ret <4 x i8> [[BSPLAT]]11;12  %xsplat = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>13  call void @use(<4 x i8> %xsplat)14  %b = add <4 x i8> %xsplat, %y15  %bsplat = shufflevector <4 x i8> %b, <4 x i8> poison, <4 x i32> zeroinitializer16  ret <4 x i8> %bsplat17}18 19define <4 x i8> @non_splat_binop_splat_x(<4 x i8> %x, <4 x i8> %y) {20; CHECK-LABEL: @non_splat_binop_splat_x(21; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> poison, <4 x i32> zeroinitializer22; CHECK-NEXT:    call void @use(<4 x i8> [[XSPLAT]])23; CHECK-NEXT:    [[B:%.*]] = sub <4 x i8> [[XSPLAT]], [[Y:%.*]]24; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x i8> [[B]], <4 x i8> poison, <4 x i32> <i32 0, i32 2, i32 poison, i32 poison>25; CHECK-NEXT:    ret <4 x i8> [[BSPLAT]]26;27  %xsplat = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> zeroinitializer28  call void @use(<4 x i8> %xsplat)29  %b = sub <4 x i8> %xsplat, %y30  %bsplat = shufflevector <4 x i8> %b, <4 x i8> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>31  ret <4 x i8> %bsplat32}33 34define <4 x i32> @splat_binop_splat_changes_x_length(<8 x i32> %x, <4 x i32> %y) {35; CHECK-LABEL: @splat_binop_splat_changes_x_length(36; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <8 x i32> [[X:%.*]], <8 x i32> poison, <4 x i32> zeroinitializer37; CHECK-NEXT:    call void @use(<4 x i32> [[XSPLAT]])38; CHECK-NEXT:    [[B:%.*]] = mul <4 x i32> [[XSPLAT]], [[Y:%.*]]39; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x i32> [[B]], <4 x i32> poison, <4 x i32> zeroinitializer40; CHECK-NEXT:    ret <4 x i32> [[BSPLAT]]41;42  %xsplat = shufflevector <8 x i32> %x, <8 x i32> poison, <4 x i32> zeroinitializer43  call void @use(<4 x i32> %xsplat)44  %b = mul <4 x i32> %xsplat, %y45  %bsplat = shufflevector <4 x i32> %b, <4 x i32> poison, <4 x i32> zeroinitializer46  ret <4 x i32> %bsplat47}48 49define <4 x i8> @splat_binop_splat_x(<4 x i8> %x, <4 x i8> %y) {50; CHECK-LABEL: @splat_binop_splat_x(51; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> poison, <4 x i32> zeroinitializer52; CHECK-NEXT:    call void @use(<4 x i8> [[XSPLAT]])53; CHECK-NEXT:    [[TMP1:%.*]] = add nsw <4 x i8> [[X]], [[Y:%.*]]54; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x i8> [[TMP1]], <4 x i8> poison, <4 x i32> zeroinitializer55; CHECK-NEXT:    ret <4 x i8> [[BSPLAT]]56;57  %xsplat = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> zeroinitializer58  call void @use(<4 x i8> %xsplat)59  %b = add nsw <4 x i8> %xsplat, %y60  %bsplat = shufflevector <4 x i8> %b, <4 x i8> poison, <4 x i32> zeroinitializer61  ret <4 x i8> %bsplat62}63 64define <4 x i8> @splat_binop_splat_y(<4 x i8> %x, <4 x i8> %y) {65; CHECK-LABEL: @splat_binop_splat_y(66; CHECK-NEXT:    [[YSPLAT:%.*]] = shufflevector <4 x i8> [[Y:%.*]], <4 x i8> poison, <4 x i32> zeroinitializer67; CHECK-NEXT:    call void @use(<4 x i8> [[YSPLAT]])68; CHECK-NEXT:    [[TMP1:%.*]] = sub <4 x i8> [[X:%.*]], [[Y]]69; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x i8> [[TMP1]], <4 x i8> poison, <4 x i32> <i32 poison, i32 0, i32 0, i32 0>70; CHECK-NEXT:    ret <4 x i8> [[BSPLAT]]71;72  %ysplat = shufflevector <4 x i8> %y, <4 x i8> poison, <4 x i32> zeroinitializer73  call void @use(<4 x i8> %ysplat)74  %b = sub <4 x i8> %x, %ysplat75  %bsplat = shufflevector <4 x i8> %b, <4 x i8> poison, <4 x i32><i32 poison, i32 0, i32 0, i32 0>76  ret <4 x i8> %bsplat77}78 79define <4 x i8> @splat_binop_splat_x_splat_y(<4 x i8> %x, <4 x i8> %y) {80; CHECK-LABEL: @splat_binop_splat_x_splat_y(81; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> poison, <4 x i32> zeroinitializer82; CHECK-NEXT:    call void @use(<4 x i8> [[XSPLAT]])83; CHECK-NEXT:    [[YSPLAT:%.*]] = shufflevector <4 x i8> [[Y:%.*]], <4 x i8> poison, <4 x i32> zeroinitializer84; CHECK-NEXT:    call void @use(<4 x i8> [[YSPLAT]])85; CHECK-NEXT:    [[TMP1:%.*]] = mul nuw <4 x i8> [[X]], [[Y]]86; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x i8> [[TMP1]], <4 x i8> poison, <4 x i32> zeroinitializer87; CHECK-NEXT:    ret <4 x i8> [[BSPLAT]]88;89  %xsplat = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> zeroinitializer90  call void @use(<4 x i8> %xsplat)91  %ysplat = shufflevector <4 x i8> %y, <4 x i8> poison, <4 x i32> zeroinitializer92  call void @use(<4 x i8> %ysplat)93  %b = mul nuw <4 x i8> %xsplat, %ysplat94  %bsplat = shufflevector <4 x i8> %b, <4 x i8> poison, <4 x i32> zeroinitializer95  ret <4 x i8> %bsplat96}97 98define <4 x float> @splat_binop_splat_x_splat_y_fmath_flags(<4 x float> %x, <4 x float> %y) {99; CHECK-LABEL: @splat_binop_splat_x_splat_y_fmath_flags(100; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <4 x float> [[X:%.*]], <4 x float> poison, <4 x i32> zeroinitializer101; CHECK-NEXT:    call void @use(<4 x float> [[XSPLAT]])102; CHECK-NEXT:    [[YSPLAT:%.*]] = shufflevector <4 x float> [[Y:%.*]], <4 x float> poison, <4 x i32> zeroinitializer103; CHECK-NEXT:    call void @use(<4 x float> [[YSPLAT]])104; CHECK-NEXT:    [[TMP1:%.*]] = fmul fast <4 x float> [[X]], [[Y]]105; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> zeroinitializer106; CHECK-NEXT:    ret <4 x float> [[BSPLAT]]107;108  %xsplat = shufflevector <4 x float> %x, <4 x float> poison, <4 x i32> zeroinitializer109  call void @use(<4 x float> %xsplat)110  %ysplat = shufflevector <4 x float> %y, <4 x float> poison, <4 x i32> zeroinitializer111  call void @use(<4 x float> %ysplat)112  %b = fmul fast <4 x float> %xsplat, %ysplat113  %bsplat = shufflevector <4 x float> %b, <4 x float> poison, <4 x i32> zeroinitializer114  ret <4 x float> %bsplat115}116 117define <vscale x 4 x i32> @vscale_splat_udiv_splat_x(<vscale x 4 x i32> %x, <vscale x 4 x i32> %y) {118; CHECK-LABEL: @vscale_splat_udiv_splat_x(119; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[X:%.*]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer120; CHECK-NEXT:    [[B:%.*]] = udiv <vscale x 4 x i32> [[XSPLAT]], [[Y:%.*]]121; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer122; CHECK-NEXT:    ret <vscale x 4 x i32> [[BSPLAT]]123;124  %xsplat = shufflevector <vscale x 4 x i32> %x, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer125  %b = udiv <vscale x 4 x i32> %xsplat, %y126  %bsplat = shufflevector <vscale x 4 x i32> %b, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer127  ret <vscale x 4 x i32> %bsplat128}129 130define <vscale x 4 x i32> @vscale_splat_urem_splat_x(<vscale x 4 x i32> %x, <vscale x 4 x i32> %y) {131; CHECK-LABEL: @vscale_splat_urem_splat_x(132; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[X:%.*]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer133; CHECK-NEXT:    [[B:%.*]] = urem <vscale x 4 x i32> [[XSPLAT]], [[Y:%.*]]134; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer135; CHECK-NEXT:    ret <vscale x 4 x i32> [[BSPLAT]]136;137  %xsplat = shufflevector <vscale x 4 x i32> %x, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer138  %b = urem <vscale x 4 x i32> %xsplat, %y139  %bsplat = shufflevector <vscale x 4 x i32> %b, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer140  ret <vscale x 4 x i32> %bsplat141}142 143define <vscale x 4 x i32> @vscale_splat_binop_splat_y(<vscale x 4 x i32> %x, <vscale x 4 x i32> %y) {144; CHECK-LABEL: @vscale_splat_binop_splat_y(145; CHECK-NEXT:    [[YSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[Y:%.*]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer146; CHECK-NEXT:    [[B:%.*]] = sdiv <vscale x 4 x i32> [[X:%.*]], [[YSPLAT]]147; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer148; CHECK-NEXT:    ret <vscale x 4 x i32> [[BSPLAT]]149;150  %ysplat = shufflevector <vscale x 4 x i32> %y, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer151  %b = sdiv <vscale x 4 x i32> %x, %ysplat152  %bsplat = shufflevector <vscale x 4 x i32> %b, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer153  ret <vscale x 4 x i32> %bsplat154}155 156define <vscale x 4 x i32> @vscale_splat_binop_splat_x_splat_y(<vscale x 4 x i32> %x, <vscale x 4 x i32> %y) {157; CHECK-LABEL: @vscale_splat_binop_splat_x_splat_y(158; CHECK-NEXT:    [[TMP1:%.*]] = ashr <vscale x 4 x i32> [[X:%.*]], [[Y:%.*]]159; CHECK-NEXT:    [[B:%.*]] = shufflevector <vscale x 4 x i32> [[TMP1]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer160; CHECK-NEXT:    ret <vscale x 4 x i32> [[B]]161;162  %xsplat = shufflevector <vscale x 4 x i32> %x, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer163  %ysplat = shufflevector <vscale x 4 x i32> %y, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer164  %b = ashr <vscale x 4 x i32> %xsplat, %ysplat165  %bsplat = shufflevector <vscale x 4 x i32> %b, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer166  ret <vscale x 4 x i32> %bsplat167}168 169define <vscale x 4 x i32> @vscale_splat_binop_splat_x_splat_y_calls(<vscale x 4 x i32> %x, <vscale x 4 x i32> %y) {170; CHECK-LABEL: @vscale_splat_binop_splat_x_splat_y_calls(171; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[X:%.*]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer172; CHECK-NEXT:    call void @use_v(<vscale x 4 x i32> [[XSPLAT]])173; CHECK-NEXT:    [[YSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[Y:%.*]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer174; CHECK-NEXT:    call void @use_v(<vscale x 4 x i32> [[YSPLAT]])175; CHECK-NEXT:    [[TMP1:%.*]] = lshr <vscale x 4 x i32> [[X]], [[Y]]176; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[TMP1]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer177; CHECK-NEXT:    ret <vscale x 4 x i32> [[BSPLAT]]178;179  %xsplat = shufflevector <vscale x 4 x i32> %x, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer180  call void @use_v(<vscale x 4 x i32> %xsplat)181  %ysplat = shufflevector <vscale x 4 x i32> %y, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer182  call void @use_v(<vscale x 4 x i32> %ysplat)183  %b = lshr <vscale x 4 x i32> %xsplat, %ysplat184  %bsplat = shufflevector <vscale x 4 x i32> %b, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer185  ret <vscale x 4 x i32> %bsplat186}187 188define <2 x double> @shuffle_op2_0th_element_mask(ptr %a, ptr %b) {189; CHECK-LABEL: @shuffle_op2_0th_element_mask(190; CHECK-NEXT:    [[TMP1:%.*]] = load <2 x double>, ptr [[A:%.*]], align 16191; CHECK-NEXT:    [[TMP2:%.*]] = load <2 x double>, ptr [[B:%.*]], align 16192; CHECK-NEXT:    [[TMP3:%.*]] = fsub <2 x double> [[TMP2]], [[TMP1]]193; CHECK-NEXT:    [[SHUFFLE:%.*]] = shufflevector <2 x double> [[TMP3]], <2 x double> poison, <2 x i32> zeroinitializer194; CHECK-NEXT:    ret <2 x double> [[SHUFFLE]]195;196  %1 = load <2 x double>, ptr %a, align 16197  %2 = shufflevector <2 x double> %1, <2 x double> poison, <2 x i32> zeroinitializer198  %3 = load <2 x double>, ptr %b, align 16199  %sub = fsub <2 x double> %3, %2200  %shuffle = shufflevector <2 x double> %sub, <2 x double> %sub, <2 x i32> <i32 2, i32 2>201  ret <2 x double> %shuffle202}203 204; This should not create an extra binop.205 206define <2 x i4> @splat_binop_splat_uses(<2 x i4> %x, <2 x i4> %y) {207; CHECK-LABEL: @splat_binop_splat_uses(208; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <2 x i4> [[X:%.*]], <2 x i4> poison, <2 x i32> zeroinitializer209; CHECK-NEXT:    [[XY:%.*]] = mul <2 x i4> [[XSPLAT]], [[Y:%.*]]210; CHECK-NEXT:    [[MSPLAT:%.*]] = shufflevector <2 x i4> [[XY]], <2 x i4> poison, <2 x i32> zeroinitializer211; CHECK-NEXT:    [[RES:%.*]] = add <2 x i4> [[XY]], [[MSPLAT]]212; CHECK-NEXT:    ret <2 x i4> [[RES]]213;214  %xsplat = shufflevector <2 x i4> %x, <2 x i4> poison, <2 x i32> zeroinitializer215  %xy = mul <2 x i4> %xsplat, %y216  %msplat = shufflevector <2 x i4> %xy, <2 x i4> poison, <2 x i32> zeroinitializer217  %res = add <2 x i4> %xy, %msplat218  ret <2 x i4> %res219}220 221declare void @use(<4 x i8>)222declare void @use_v(<vscale x 4 x i32>)223