llvm.org GIT mirror llvm / a0a6553
[X86][AVX512] Improve support for signed saturation truncation stores Matches what we already manage for unsigned saturation truncation stores Differential Revision: https://reviews.llvm.org/D43629 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326372 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Pilgrim 2 years ago
2 changed file(s) with 23 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
3434834348 return SDValue();
3434934349 }
3435034350
34351 /// Detect a pattern of truncation with signed saturation.
34352 /// The types should allow to use VPMOVSS* instruction on AVX512.
34353 /// Return the source value to be truncated or SDValue() if the pattern was not
34354 /// matched.
34355 static SDValue detectAVX512SSatPattern(SDValue In, EVT VT,
34356 const X86Subtarget &Subtarget,
34357 const TargetLowering &TLI) {
34358 if (!TLI.isTypeLegal(In.getValueType()))
34359 return SDValue();
34360 if (!isSATValidOnAVX512Subtarget(In.getValueType(), VT, Subtarget))
34361 return SDValue();
34362 return detectSSatPattern(In, VT);
34363 }
34364
3435134365 /// Detect a pattern of truncation with saturation:
3435234366 /// (truncate (umin (x, unsigned_max_of_dest_type)) to dest_type).
3435334367 /// The types should allow to use VPMOVUS* instruction on AVX512.
3498635000 St->getMemOperand()->getFlags());
3498735001
3498835002 const TargetLowering &TLI = DAG.getTargetLoweringInfo();
35003 if (SDValue Val =
35004 detectAVX512SSatPattern(St->getValue(), St->getMemoryVT(), Subtarget,
35005 TLI))
35006 return EmitTruncSStore(true /* Signed saturation */, St->getChain(),
35007 dl, Val, St->getBasePtr(),
35008 St->getMemoryVT(), St->getMemOperand(), DAG);
3498935009 if (SDValue Val =
3499035010 detectAVX512USatPattern(St->getValue(), St->getMemoryVT(), Subtarget,
3499135011 TLI))
20412041 ;
20422042 ; AVX512-LABEL: trunc_ssat_v8i64_v8i8_store:
20432043 ; AVX512: # %bb.0:
2044 ; AVX512-NEXT: vpminsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
2045 ; AVX512-NEXT: vpmaxsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
2046 ; AVX512-NEXT: vpmovqb %zmm0, (%rdi)
2044 ; AVX512-NEXT: vpmovsqb %zmm0, (%rdi)
20472045 ; AVX512-NEXT: vzeroupper
20482046 ; AVX512-NEXT: retq
20492047 %1 = icmp slt <8 x i64> %a0,
29972995 ;
29982996 ; AVX512VL-LABEL: trunc_ssat_v8i32_v8i8_store:
29992997 ; AVX512VL: # %bb.0:
3000 ; AVX512VL-NEXT: vpminsd {{.*}}(%rip){1to8}, %ymm0, %ymm0
3001 ; AVX512VL-NEXT: vpmaxsd {{.*}}(%rip){1to8}, %ymm0, %ymm0
3002 ; AVX512VL-NEXT: vpmovdb %ymm0, (%rdi)
2998 ; AVX512VL-NEXT: vpmovsdb %ymm0, (%rdi)
30032999 ; AVX512VL-NEXT: vzeroupper
30043000 ; AVX512VL-NEXT: retq
30053001 ;
30173013 ;
30183014 ; AVX512BWVL-LABEL: trunc_ssat_v8i32_v8i8_store:
30193015 ; AVX512BWVL: # %bb.0:
3020 ; AVX512BWVL-NEXT: vpminsd {{.*}}(%rip){1to8}, %ymm0, %ymm0
3021 ; AVX512BWVL-NEXT: vpmaxsd {{.*}}(%rip){1to8}, %ymm0, %ymm0
3022 ; AVX512BWVL-NEXT: vpmovdb %ymm0, (%rdi)
3016 ; AVX512BWVL-NEXT: vpmovsdb %ymm0, (%rdi)
30233017 ; AVX512BWVL-NEXT: vzeroupper
30243018 ; AVX512BWVL-NEXT: retq
30253019 %1 = icmp slt <8 x i32> %a0,