From: Craig Topper Date: Sat, 17 Aug 2019 22:46:15 +0000 (+0000) Subject: [X86] Add a one use check to the combineStore code that handles v16i16->v16i8 truncat... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b90d51eebbe53789773168228e50694076daf980;p=llvm [X86] Add a one use check to the combineStore code that handles v16i16->v16i8 truncate+store by extending to v16i32 and then emitting a v16i32->v16i8 truncstore. This prevent us from emitting a separate truncate and a truncating store instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369200 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 207782bc80b..37d84892791 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -39581,7 +39581,7 @@ static SDValue combineStore(SDNode *N, SelectionDAG &DAG, St->getValue().getOpcode() == ISD::TRUNCATE && St->getValue().getOperand(0).getValueType() == MVT::v16i16 && TLI.isTruncStoreLegal(MVT::v16i32, MVT::v16i8) && - !DCI.isBeforeLegalizeOps()) { + St->getValue().hasOneUse() && !DCI.isBeforeLegalizeOps()) { SDValue Ext = DAG.getNode(ISD::ANY_EXTEND, dl, MVT::v16i32, St->getValue()); return DAG.getTruncStore(St->getChain(), dl, Ext, St->getBasePtr(), MVT::v16i8, St->getMemOperand()); diff --git a/test/CodeGen/X86/avx512-trunc.ll b/test/CodeGen/X86/avx512-trunc.ll index 572b6065b2f..45384a4df4f 100644 --- a/test/CodeGen/X86/avx512-trunc.ll +++ b/test/CodeGen/X86/avx512-trunc.ll @@ -514,6 +514,26 @@ define void @trunc_wb_256_mem(<16 x i16> %i, <16 x i8>* %res) #0 { ret void } +define <16 x i8> @trunc_wb_256_mem_and_ret(<16 x i16> %i, <16 x i8>* %res) #0 { +; KNL-LABEL: trunc_wb_256_mem_and_ret: +; KNL: ## %bb.0: +; KNL-NEXT: vpmovzxwd {{.*#+}} zmm0 = ymm0[0],zero,ymm0[1],zero,ymm0[2],zero,ymm0[3],zero,ymm0[4],zero,ymm0[5],zero,ymm0[6],zero,ymm0[7],zero,ymm0[8],zero,ymm0[9],zero,ymm0[10],zero,ymm0[11],zero,ymm0[12],zero,ymm0[13],zero,ymm0[14],zero,ymm0[15],zero +; KNL-NEXT: vpmovdb %zmm0, %xmm0 +; KNL-NEXT: vmovdqa %xmm0, (%rdi) +; KNL-NEXT: vzeroupper +; KNL-NEXT: retq +; +; SKX-LABEL: trunc_wb_256_mem_and_ret: +; SKX: ## %bb.0: +; SKX-NEXT: vpmovwb %ymm0, %xmm0 +; SKX-NEXT: vmovdqa %xmm0, (%rdi) +; SKX-NEXT: vzeroupper +; SKX-NEXT: retq + %x = trunc <16 x i16> %i to <16 x i8> + store <16 x i8> %x, <16 x i8>* %res + ret <16 x i8> %x +} + define <8 x i8> @trunc_wb_128(<8 x i16> %i) #0 { ; ALL-LABEL: trunc_wb_128: ; ALL: ## %bb.0: