brintos

brintos / llvm-project-archived public Read only

0
0
Text · 12.5 KiB · 32dccd3 Raw
174 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=slp-vectorizer -mtriple=x86_64-- -mcpu=x86-64    -S | FileCheck %s --check-prefixes=SSE23; RUN: opt < %s -passes=slp-vectorizer -mtriple=x86_64-- -mcpu=x86-64-v2 -S | FileCheck %s --check-prefixes=SSE424; RUN: opt < %s -passes=slp-vectorizer -mtriple=x86_64-- -mcpu=x86-64-v3 -S | FileCheck %s --check-prefixes=AVX25; RUN: opt < %s -passes=slp-vectorizer -mtriple=x86_64-- -mcpu=x86-64-v4 -S | FileCheck %s --check-prefixes=AVX5126 7; PR517468; typedef int v4si __attribute__ ((vector_size (16)));9;10; inline int reduce_and4(int acc, v4si v1, v4si v2, v4si v3, v4si v4) {11;   acc &= v1[0] & v1[1] & v1[2] & v1[3];12;   acc &= v2[0] & v2[1] & v2[2] & v2[3];13;   acc &= v3[0] & v3[1] & v3[2] & v3[3];14;   acc &= v4[0] & v4[1] & v4[2] & v4[3];15;   return acc;16; }17 18define i32 @reduce_and4(i32 %acc, <4 x i32> %v1, <4 x i32> %v2, <4 x i32> %v3, <4 x i32> %v4) {19; SSE2-LABEL: @reduce_and4(20; SSE2-NEXT:  entry:21; SSE2-NEXT:    [[TMP0:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>22; SSE2-NEXT:    [[TMP1:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>23; SSE2-NEXT:    [[TMP2:%.*]] = shufflevector <16 x i32> [[TMP0]], <16 x i32> [[TMP1]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 poison, i32 poison, i32 poison, i32 poison>24; SSE2-NEXT:    [[TMP3:%.*]] = shufflevector <4 x i32> [[V1:%.*]], <4 x i32> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>25; SSE2-NEXT:    [[TMP4:%.*]] = shufflevector <16 x i32> [[TMP2]], <16 x i32> [[TMP3]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 16, i32 17, i32 18, i32 19>26; SSE2-NEXT:    [[TMP5:%.*]] = call i32 @llvm.vector.reduce.and.v16i32(<16 x i32> [[TMP4]])27; SSE2-NEXT:    [[OP_RDX:%.*]] = and i32 [[TMP5]], [[ACC:%.*]]28; SSE2-NEXT:    ret i32 [[OP_RDX]]29;30; SSE42-LABEL: @reduce_and4(31; SSE42-NEXT:  entry:32; SSE42-NEXT:    [[TMP0:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>33; SSE42-NEXT:    [[TMP1:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>34; SSE42-NEXT:    [[TMP2:%.*]] = shufflevector <16 x i32> [[TMP0]], <16 x i32> [[TMP1]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 poison, i32 poison, i32 poison, i32 poison>35; SSE42-NEXT:    [[TMP3:%.*]] = shufflevector <4 x i32> [[V1:%.*]], <4 x i32> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>36; SSE42-NEXT:    [[TMP4:%.*]] = shufflevector <16 x i32> [[TMP2]], <16 x i32> [[TMP3]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 16, i32 17, i32 18, i32 19>37; SSE42-NEXT:    [[TMP5:%.*]] = call i32 @llvm.vector.reduce.and.v16i32(<16 x i32> [[TMP4]])38; SSE42-NEXT:    [[OP_RDX:%.*]] = and i32 [[TMP5]], [[ACC:%.*]]39; SSE42-NEXT:    ret i32 [[OP_RDX]]40;41; AVX2-LABEL: @reduce_and4(42; AVX2-NEXT:  entry:43; AVX2-NEXT:    [[TMP0:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <8 x i32> <i32 1, i32 0, i32 2, i32 3, i32 5, i32 4, i32 6, i32 7>44; AVX2-NEXT:    [[TMP1:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> [[V1:%.*]], <8 x i32> <i32 1, i32 0, i32 2, i32 3, i32 5, i32 4, i32 6, i32 7>45; AVX2-NEXT:    [[TMP2:%.*]] = shufflevector <8 x i32> [[TMP0]], <8 x i32> [[TMP1]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>46; AVX2-NEXT:    [[TMP3:%.*]] = call i32 @llvm.vector.reduce.and.v16i32(<16 x i32> [[TMP2]])47; AVX2-NEXT:    [[OP_RDX:%.*]] = and i32 [[TMP3]], [[ACC:%.*]]48; AVX2-NEXT:    ret i32 [[OP_RDX]]49;50; AVX512-LABEL: @reduce_and4(51; AVX512-NEXT:  entry:52; AVX512-NEXT:    [[TMP0:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <8 x i32> <i32 1, i32 0, i32 2, i32 3, i32 5, i32 4, i32 6, i32 7>53; AVX512-NEXT:    [[TMP1:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> [[V1:%.*]], <8 x i32> <i32 1, i32 0, i32 2, i32 3, i32 5, i32 4, i32 6, i32 7>54; AVX512-NEXT:    [[RDX_OP:%.*]] = and <8 x i32> [[TMP0]], [[TMP1]]55; AVX512-NEXT:    [[OP_RDX:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[RDX_OP]])56; AVX512-NEXT:    [[OP_RDX1:%.*]] = and i32 [[OP_RDX]], [[ACC:%.*]]57; AVX512-NEXT:    ret i32 [[OP_RDX1]]58;59entry:60  %vecext = extractelement <4 x i32> %v1, i64 061  %vecext1 = extractelement <4 x i32> %v1, i64 162  %vecext2 = extractelement <4 x i32> %v1, i64 263  %vecext4 = extractelement <4 x i32> %v1, i64 364  %vecext7 = extractelement <4 x i32> %v2, i64 065  %vecext8 = extractelement <4 x i32> %v2, i64 166  %vecext10 = extractelement <4 x i32> %v2, i64 267  %vecext12 = extractelement <4 x i32> %v2, i64 368  %vecext15 = extractelement <4 x i32> %v3, i64 069  %vecext16 = extractelement <4 x i32> %v3, i64 170  %vecext18 = extractelement <4 x i32> %v3, i64 271  %vecext20 = extractelement <4 x i32> %v3, i64 372  %vecext23 = extractelement <4 x i32> %v4, i64 073  %vecext24 = extractelement <4 x i32> %v4, i64 174  %vecext26 = extractelement <4 x i32> %v4, i64 275  %vecext28 = extractelement <4 x i32> %v4, i64 376  %and25 = and i32 %vecext1, %acc77  %and27 = and i32 %and25, %vecext78  %and29 = and i32 %and27, %vecext279  %and17 = and i32 %and29, %vecext480  %and19 = and i32 %and17, %vecext881  %and21 = and i32 %and19, %vecext782  %and9 = and i32 %and21, %vecext1083  %and11 = and i32 %and9, %vecext1284  %and13 = and i32 %and11, %vecext1685  %and = and i32 %and13, %vecext1586  %and3 = and i32 %and, %vecext1887  %and5 = and i32 %and3, %vecext2088  %and6 = and i32 %and5, %vecext2489  %and14 = and i32 %and6, %vecext2390  %and22 = and i32 %and14, %vecext2691  %and30 = and i32 %and22, %vecext2892  ret i32 %and3093}94 95; int reduce_and4_transpose(int acc, v4si v1, v4si v2, v4si v3, v4si v4) {96;   acc &= v1[0] & v2[0] & v3[0] & v4[0];97;   acc &= v1[1] & v2[1] & v3[1] & v4[1];98;   acc &= v1[2] & v2[2] & v3[2] & v4[2];99;   acc &= v1[3] & v2[3] & v3[3] & v4[3];100;   return acc;101; }102 103define i32 @reduce_and4_transpose(i32 %acc, <4 x i32> %v1, <4 x i32> %v2, <4 x i32> %v3, <4 x i32> %v4) {104; SSE2-LABEL: @reduce_and4_transpose(105; SSE2-NEXT:    [[TMP1:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>106; SSE2-NEXT:    [[TMP2:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>107; SSE2-NEXT:    [[TMP3:%.*]] = shufflevector <16 x i32> [[TMP1]], <16 x i32> [[TMP2]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 poison, i32 poison, i32 poison, i32 poison>108; SSE2-NEXT:    [[TMP4:%.*]] = shufflevector <4 x i32> [[V1:%.*]], <4 x i32> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>109; SSE2-NEXT:    [[TMP5:%.*]] = shufflevector <16 x i32> [[TMP3]], <16 x i32> [[TMP4]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 16, i32 17, i32 18, i32 19>110; SSE2-NEXT:    [[TMP6:%.*]] = call i32 @llvm.vector.reduce.and.v16i32(<16 x i32> [[TMP5]])111; SSE2-NEXT:    [[OP_RDX:%.*]] = and i32 [[TMP6]], [[ACC:%.*]]112; SSE2-NEXT:    ret i32 [[OP_RDX]]113;114; SSE42-LABEL: @reduce_and4_transpose(115; SSE42-NEXT:    [[TMP1:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>116; SSE42-NEXT:    [[TMP2:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>117; SSE42-NEXT:    [[TMP3:%.*]] = shufflevector <16 x i32> [[TMP1]], <16 x i32> [[TMP2]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 poison, i32 poison, i32 poison, i32 poison>118; SSE42-NEXT:    [[TMP4:%.*]] = shufflevector <4 x i32> [[V1:%.*]], <4 x i32> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>119; SSE42-NEXT:    [[TMP5:%.*]] = shufflevector <16 x i32> [[TMP3]], <16 x i32> [[TMP4]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 16, i32 17, i32 18, i32 19>120; SSE42-NEXT:    [[TMP6:%.*]] = call i32 @llvm.vector.reduce.and.v16i32(<16 x i32> [[TMP5]])121; SSE42-NEXT:    [[OP_RDX:%.*]] = and i32 [[TMP6]], [[ACC:%.*]]122; SSE42-NEXT:    ret i32 [[OP_RDX]]123;124; AVX2-LABEL: @reduce_and4_transpose(125; AVX2-NEXT:    [[TMP1:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>126; AVX2-NEXT:    [[TMP2:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> [[V1:%.*]], <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>127; AVX2-NEXT:    [[TMP3:%.*]] = shufflevector <8 x i32> [[TMP1]], <8 x i32> [[TMP2]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>128; AVX2-NEXT:    [[TMP4:%.*]] = call i32 @llvm.vector.reduce.and.v16i32(<16 x i32> [[TMP3]])129; AVX2-NEXT:    [[OP_RDX:%.*]] = and i32 [[TMP4]], [[ACC:%.*]]130; AVX2-NEXT:    ret i32 [[OP_RDX]]131;132; AVX512-LABEL: @reduce_and4_transpose(133; AVX512-NEXT:    [[TMP1:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>134; AVX512-NEXT:    [[TMP2:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> [[V1:%.*]], <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>135; AVX512-NEXT:    [[RDX_OP:%.*]] = and <8 x i32> [[TMP1]], [[TMP2]]136; AVX512-NEXT:    [[OP_RDX:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[RDX_OP]])137; AVX512-NEXT:    [[OP_RDX1:%.*]] = and i32 [[OP_RDX]], [[ACC:%.*]]138; AVX512-NEXT:    ret i32 [[OP_RDX1]]139;140  %vecext = extractelement <4 x i32> %v1, i64 0141  %vecext1 = extractelement <4 x i32> %v2, i64 0142  %vecext2 = extractelement <4 x i32> %v3, i64 0143  %vecext4 = extractelement <4 x i32> %v4, i64 0144  %vecext7 = extractelement <4 x i32> %v1, i64 1145  %vecext8 = extractelement <4 x i32> %v2, i64 1146  %vecext10 = extractelement <4 x i32> %v3, i64 1147  %vecext12 = extractelement <4 x i32> %v4, i64 1148  %vecext15 = extractelement <4 x i32> %v1, i64 2149  %vecext16 = extractelement <4 x i32> %v2, i64 2150  %vecext18 = extractelement <4 x i32> %v3, i64 2151  %vecext20 = extractelement <4 x i32> %v4, i64 2152  %vecext23 = extractelement <4 x i32> %v1, i64 3153  %vecext24 = extractelement <4 x i32> %v2, i64 3154  %vecext26 = extractelement <4 x i32> %v3, i64 3155  %vecext28 = extractelement <4 x i32> %v4, i64 3156  %and = and i32 %vecext23, %acc157  %and3 = and i32 %and, %vecext15158  %and5 = and i32 %and3, %vecext7159  %and6 = and i32 %and5, %vecext160  %and9 = and i32 %and6, %vecext24161  %and11 = and i32 %and9, %vecext16162  %and13 = and i32 %and11, %vecext8163  %and14 = and i32 %and13, %vecext1164  %and17 = and i32 %and14, %vecext26165  %and19 = and i32 %and17, %vecext18166  %and21 = and i32 %and19, %vecext10167  %and22 = and i32 %and21, %vecext2168  %and25 = and i32 %and22, %vecext28169  %and27 = and i32 %and25, %vecext20170  %and29 = and i32 %and27, %vecext12171  %and30 = and i32 %and29, %vecext4172  ret i32 %and30173}174