[llvm] [SystemZ] Don't scalarize truncating vector fp to uint conversions. (PR #205311)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 23 03:18:57 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis

@llvm/pr-subscribers-backend-systemz

Author: Jonas Paulsson (JonPsson1)

<details>
<summary>Changes</summary>

It should be better to use vector fp to uint conversions followed by vperm
(and vpdi) than scalarization.

This however only affected three benchmarks (15 files), so it may not be worth having. However, imagick actually showed an improvement (2.5%), but this benchmark has been "volatile" in the past, so I would like to try this again after rebasing on top of the new scheduling strategy to see what it looks like then.

This was discovered when investigating cost functions with LoopVectorizer / LoopUnroller.


---

Patch is 28.07 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/205311.diff


5 Files Affected:

- (modified) llvm/lib/Target/SystemZ/SystemZISelLowering.cpp (+47) 
- (modified) llvm/lib/Target/SystemZ/SystemZISelLowering.h (+1) 
- (modified) llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp (+6) 
- (modified) llvm/test/Analysis/CostModel/SystemZ/fp-cast.ll (+28-20) 
- (added) llvm/test/CodeGen/SystemZ/vec-conv-04.ll (+437) 


``````````diff
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index e56a449cd455d..1f805812b32cf 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -787,6 +787,7 @@ SystemZTargetLowering::SystemZTargetLowering(const TargetMachine &TM,
                        ISD::FP_EXTEND,
                        ISD::SINT_TO_FP,
                        ISD::UINT_TO_FP,
+                       ISD::FP_TO_UINT,
                        ISD::STRICT_FP_EXTEND,
                        ISD::FCOPYSIGN,
                        ISD::BSWAP,
@@ -8586,6 +8587,51 @@ SDValue SystemZTargetLowering::combineINT_TO_FP(
   return SDValue();
 }
 
+SDValue SystemZTargetLowering::combineFP_TO_UINT(
+    SDNode *N, DAGCombinerInfo &DCI) const {
+  if (DCI.Level != BeforeLegalizeTypes)
+    return SDValue();
+  SelectionDAG &DAG = DCI.DAG;
+  LLVMContext &Ctx = *DAG.getContext();
+  SDLoc DL(N);
+  EVT OutVT = N->getValueType(0);
+  Type *OutLLVMTy = OutVT.getTypeForEVT(Ctx);
+  SDValue Op = N->getOperand(0);
+  unsigned OutScalarBits = OutVT.getScalarSizeInBits();
+  unsigned InScalarBits = Op->getValueType(0).getScalarSizeInBits();
+  // Do a vector conversion followed by a permute to avoid expansion into
+  // scalar conversions.
+  if (OutLLVMTy->isVectorTy() && OutScalarBits < InScalarBits &&
+      InScalarBits <= 64 && isPowerOf2_32(InScalarBits) &&
+      isPowerOf2_32(OutScalarBits)) {
+    // Vector conversion to same bitwidth.
+    unsigned NumElts = cast<FixedVectorType>(OutLLVMTy)->getNumElements();
+    EVT ConvVT = EVT::getVectorVT(Ctx, EVT::getIntegerVT(Ctx, InScalarBits),
+                                  NumElts);
+    SDValue ConvOp = DAG.getNode(ISD::FP_TO_UINT, DL, ConvVT, Op);
+
+    // Bitcast to narrow elements vector type.
+    unsigned NumTruncElts = ConvVT.getSizeInBits() / OutScalarBits;
+    EVT TruncEltVT = OutVT.getVectorElementType();
+    EVT TruncVecVT = EVT::getVectorVT(Ctx, TruncEltVT, NumTruncElts);
+    SDValue BCast = DAG.getBitcast(TruncVecVT, ConvOp);
+
+    // Build the result vector.
+    unsigned EltFac = InScalarBits / OutScalarBits;
+    SmallVector<SDValue, SystemZ::VectorBytes> Ops;
+    unsigned I = 0;
+    for (; I < NumElts ; ++I)
+      Ops.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, TruncEltVT,
+                        BCast, DAG.getConstant(I * EltFac, DL, MVT::i32)));
+    for (; I < NumTruncElts; ++I)
+      Ops.push_back(DAG.getUNDEF(TruncEltVT));
+    SDValue BV = DAG.getBuildVector(TruncVecVT, DL, Ops);
+    return DAG.getExtractSubvector(DL, OutVT, BV, 0);
+  }
+
+  return SDValue();
+}
+
 SDValue SystemZTargetLowering::combineFCOPYSIGN(
     SDNode *N, DAGCombinerInfo &DCI) const {
   SelectionDAG &DAG = DCI.DAG;
@@ -9424,6 +9470,7 @@ SDValue SystemZTargetLowering::PerformDAGCombine(SDNode *N,
   case ISD::FP_EXTEND:          return combineFP_EXTEND(N, DCI);
   case ISD::SINT_TO_FP:
   case ISD::UINT_TO_FP:         return combineINT_TO_FP(N, DCI);
+  case ISD::FP_TO_UINT:         return combineFP_TO_UINT(N, DCI);
   case ISD::FCOPYSIGN:          return combineFCOPYSIGN(N, DCI);
   case ISD::BSWAP:              return combineBSWAP(N, DCI);
   case ISD::SETCC:              return combineSETCC(N, DCI);
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.h b/llvm/lib/Target/SystemZ/SystemZISelLowering.h
index 7facd3a27d97c..5f092bb8a1204 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.h
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.h
@@ -416,6 +416,7 @@ class SystemZTargetLowering : public TargetLowering {
   SDValue combineFP_ROUND(SDNode *N, DAGCombinerInfo &DCI) const;
   SDValue combineFP_EXTEND(SDNode *N, DAGCombinerInfo &DCI) const;
   SDValue combineINT_TO_FP(SDNode *N, DAGCombinerInfo &DCI) const;
+  SDValue combineFP_TO_UINT(SDNode *N, DAGCombinerInfo &DCI) const;
   SDValue combineFCOPYSIGN(SDNode *N, DAGCombinerInfo &DCI) const;
   SDValue combineBSWAP(SDNode *N, DAGCombinerInfo &DCI) const;
   SDValue combineSETCC(SDNode *N, DAGCombinerInfo &DCI) const;
diff --git a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
index 8932b90f5ff02..494635124c41b 100644
--- a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
@@ -1067,6 +1067,12 @@ InstructionCost SystemZTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
           return getBoolVecToIntConversionCost(Opcode, Dst, I) + NumDstVectors;
       }
 
+      // These will use vector conversions followed by vector permutes.
+      if (Opcode == Instruction::FPToUI && SrcScalarBits <= 64 &&
+          DstScalarBits < SrcScalarBits &&
+          (SrcScalarBits == 64 || ST->hasVectorEnhancements2()))
+        return NumSrcVectors * 2;
+
       // Return the cost of multiple scalar invocation plus the cost of
       // inserting and extracting the values. Base implementation does not
       // realize float->int gets scalarized.
diff --git a/llvm/test/Analysis/CostModel/SystemZ/fp-cast.ll b/llvm/test/Analysis/CostModel/SystemZ/fp-cast.ll
index 837962cb98018..46a96b849db1c 100644
--- a/llvm/test/Analysis/CostModel/SystemZ/fp-cast.ll
+++ b/llvm/test/Analysis/CostModel/SystemZ/fp-cast.ll
@@ -236,49 +236,57 @@ define void @fptoui() {
 ; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %v14 = fptoui <2 x fp128> undef to <2 x i16>
 ; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %v15 = fptoui <2 x fp128> undef to <2 x i8>
 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %v16 = fptoui <2 x double> undef to <2 x i64>
-; CHECK: Cost Model: Found an estimated cost of 6 for instruction:   %v17 = fptoui <2 x double> undef to <2 x i32>
-; CHECK: Cost Model: Found an estimated cost of 6 for instruction:   %v18 = fptoui <2 x double> undef to <2 x i16>
-; CHECK: Cost Model: Found an estimated cost of 6 for instruction:   %v19 = fptoui <2 x double> undef to <2 x i8>
+; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %v17 = fptoui <2 x double> undef to <2 x i32>
+; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %v18 = fptoui <2 x double> undef to <2 x i16>
+; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %v19 = fptoui <2 x double> undef to <2 x i8>
 ; CHECK: Cost Model: Found an estimated cost of 5 for instruction:   %v20 = fptoui <2 x float> undef to <2 x i64>
 ; Z13:   Cost Model: Found an estimated cost of 12 for instruction:   %v21 = fptoui <2 x float> undef to <2 x i32>
 ; Z15:   Cost Model: Found an estimated cost of 1 for instruction:   %v21 = fptoui <2 x float> undef to <2 x i32>
-; CHECK: Cost Model: Found an estimated cost of 6 for instruction:   %v22 = fptoui <2 x float> undef to <2 x i16>
-; CHECK: Cost Model: Found an estimated cost of 6 for instruction:   %v23 = fptoui <2 x float> undef to <2 x i8>
+; Z13:   Cost Model: Found an estimated cost of 6 for instruction:   %v22 = fptoui <2 x float> undef to <2 x i16>
+; Z15:   Cost Model: Found an estimated cost of 2 for instruction:   %v22 = fptoui <2 x float> undef to <2 x i16>
+; Z13:   Cost Model: Found an estimated cost of 6 for instruction:   %v23 = fptoui <2 x float> undef to <2 x i8>
+; Z15:   Cost Model: Found an estimated cost of 2 for instruction:   %v23 = fptoui <2 x float> undef to <2 x i8>
 ; CHECK: Cost Model: Found an estimated cost of 6 for instruction:   %v24 = fptoui <4 x fp128> undef to <4 x i64>
 ; CHECK: Cost Model: Found an estimated cost of 8 for instruction:   %v25 = fptoui <4 x fp128> undef to <4 x i32>
 ; CHECK: Cost Model: Found an estimated cost of 8 for instruction:   %v26 = fptoui <4 x fp128> undef to <4 x i16>
 ; CHECK: Cost Model: Found an estimated cost of 8 for instruction:   %v27 = fptoui <4 x fp128> undef to <4 x i8>
 ; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %v28 = fptoui <4 x double> undef to <4 x i64>
-; CHECK: Cost Model: Found an estimated cost of 12 for instruction:   %v29 = fptoui <4 x double> undef to <4 x i32>
-; CHECK: Cost Model: Found an estimated cost of 12 for instruction:   %v30 = fptoui <4 x double> undef to <4 x i16>
-; CHECK: Cost Model: Found an estimated cost of 12 for instruction:   %v31 = fptoui <4 x double> undef to <4 x i8>
+; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %v29 = fptoui <4 x double> undef to <4 x i32>
+; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %v30 = fptoui <4 x double> undef to <4 x i16>
+; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %v31 = fptoui <4 x double> undef to <4 x i8>
 ; CHECK: Cost Model: Found an estimated cost of 10 for instruction:   %v32 = fptoui <4 x float> undef to <4 x i64>
 ; Z13:   Cost Model: Found an estimated cost of 12 for instruction:   %v33 = fptoui <4 x float> undef to <4 x i32>
 ; Z15:   Cost Model: Found an estimated cost of 1 for instruction:   %v33 = fptoui <4 x float> undef to <4 x i32>
-; CHECK: Cost Model: Found an estimated cost of 12 for instruction:   %v34 = fptoui <4 x float> undef to <4 x i16>
-; CHECK: Cost Model: Found an estimated cost of 12 for instruction:   %v35 = fptoui <4 x float> undef to <4 x i8>
+; Z13:   Cost Model: Found an estimated cost of 12 for instruction:   %v34 = fptoui <4 x float> undef to <4 x i16>
+; Z15:   Cost Model: Found an estimated cost of 2 for instruction:   %v34 = fptoui <4 x float> undef to <4 x i16>
+; Z13:   Cost Model: Found an estimated cost of 12 for instruction:   %v35 = fptoui <4 x float> undef to <4 x i8>
+; Z15:   Cost Model: Found an estimated cost of 2 for instruction:   %v35 = fptoui <4 x float> undef to <4 x i8>
 ; CHECK: Cost Model: Found an estimated cost of 12 for instruction:   %v36 = fptoui <8 x fp128> undef to <8 x i64>
 ; CHECK: Cost Model: Found an estimated cost of 16 for instruction:   %v37 = fptoui <8 x fp128> undef to <8 x i32>
 ; CHECK: Cost Model: Found an estimated cost of 16 for instruction:   %v38 = fptoui <8 x fp128> undef to <8 x i16>
 ; CHECK: Cost Model: Found an estimated cost of 16 for instruction:   %v39 = fptoui <8 x fp128> undef to <8 x i8>
 ; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %v40 = fptoui <8 x double> undef to <8 x i64>
-; CHECK: Cost Model: Found an estimated cost of 24 for instruction:   %v41 = fptoui <8 x double> undef to <8 x i32>
-; CHECK: Cost Model: Found an estimated cost of 24 for instruction:   %v42 = fptoui <8 x double> undef to <8 x i16>
-; CHECK: Cost Model: Found an estimated cost of 24 for instruction:   %v43 = fptoui <8 x double> undef to <8 x i8>
+; CHECK: Cost Model: Found an estimated cost of 8 for instruction:   %v41 = fptoui <8 x double> undef to <8 x i32>
+; CHECK: Cost Model: Found an estimated cost of 8 for instruction:   %v42 = fptoui <8 x double> undef to <8 x i16>
+; CHECK: Cost Model: Found an estimated cost of 8 for instruction:   %v43 = fptoui <8 x double> undef to <8 x i8>
 ; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %v44 = fptoui <8 x float> undef to <8 x i64>
 ; Z13:   Cost Model: Found an estimated cost of 24 for instruction:   %v45 = fptoui <8 x float> undef to <8 x i32>
 ; Z15:   Cost Model: Found an estimated cost of 2 for instruction:   %v45 = fptoui <8 x float> undef to <8 x i32>
-; CHECK: Cost Model: Found an estimated cost of 24 for instruction:   %v46 = fptoui <8 x float> undef to <8 x i16>
-; CHECK: Cost Model: Found an estimated cost of 24 for instruction:   %v47 = fptoui <8 x float> undef to <8 x i8>
+; Z13:   Cost Model: Found an estimated cost of 24 for instruction:   %v46 = fptoui <8 x float> undef to <8 x i16>
+; Z15:   Cost Model: Found an estimated cost of 4 for instruction:   %v46 = fptoui <8 x float> undef to <8 x i16>
+; Z13:   Cost Model: Found an estimated cost of 24 for instruction:   %v47 = fptoui <8 x float> undef to <8 x i8>
+; Z15:   Cost Model: Found an estimated cost of 4 for instruction:   %v47 = fptoui <8 x float> undef to <8 x i8>
 ; CHECK: Cost Model: Found an estimated cost of 8 for instruction:   %v48 = fptoui <16 x double> undef to <16 x i64>
-; CHECK: Cost Model: Found an estimated cost of 48 for instruction:   %v49 = fptoui <16 x double> undef to <16 x i32>
-; CHECK: Cost Model: Found an estimated cost of 48 for instruction:   %v50 = fptoui <16 x double> undef to <16 x i16>
-; CHECK: Cost Model: Found an estimated cost of 48 for instruction:   %v51 = fptoui <16 x double> undef to <16 x i8>
+; CHECK: Cost Model: Found an estimated cost of 16 for instruction:   %v49 = fptoui <16 x double> undef to <16 x i32>
+; CHECK: Cost Model: Found an estimated cost of 16 for instruction:   %v50 = fptoui <16 x double> undef to <16 x i16>
+; CHECK: Cost Model: Found an estimated cost of 16 for instruction:   %v51 = fptoui <16 x double> undef to <16 x i8>
 ; CHECK: Cost Model: Found an estimated cost of 40 for instruction:   %v52 = fptoui <16 x float> undef to <16 x i64>
 ; Z13:   Cost Model: Found an estimated cost of 48 for instruction:   %v53 = fptoui <16 x float> undef to <16 x i32>
 ; Z15:   Cost Model: Found an estimated cost of 4 for instruction:   %v53 = fptoui <16 x float> undef to <16 x i32>
-; CHECK: Cost Model: Found an estimated cost of 48 for instruction:   %v54 = fptoui <16 x float> undef to <16 x i16>
-; CHECK: Cost Model: Found an estimated cost of 48 for instruction:   %v55 = fptoui <16 x float> undef to <16 x i8>
+; Z13:   Cost Model: Found an estimated cost of 48 for instruction:   %v54 = fptoui <16 x float> undef to <16 x i16>
+; Z15:   Cost Model: Found an estimated cost of 8 for instruction:   %v54 = fptoui <16 x float> undef to <16 x i16>
+; Z13:   Cost Model: Found an estimated cost of 48 for instruction:   %v55 = fptoui <16 x float> undef to <16 x i8>
+; Z15:   Cost Model: Found an estimated cost of 8 for instruction:   %v55 = fptoui <16 x float> undef to <16 x i8>
 
   ret void;
 }
diff --git a/llvm/test/CodeGen/SystemZ/vec-conv-04.ll b/llvm/test/CodeGen/SystemZ/vec-conv-04.ll
new file mode 100644
index 0000000000000..ee246fa97b4f8
--- /dev/null
+++ b/llvm/test/CodeGen/SystemZ/vec-conv-04.ll
@@ -0,0 +1,437 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; Test truncating vector conversions from fp to unsigned.
+;
+; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z17 | FileCheck %s
+
+define <1 x i8> @fun0(<1 x float> %V) {
+; CHECK-LABEL: fun0:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclfeb %v24, %v24, 0, 5
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <1 x float> %V to <1 x i8>
+  ret <1 x i8> %Res
+}
+
+define <2 x i8> @fun1(<2 x float> %V) {
+; CHECK-LABEL: fun1:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclfeb %v0, %v24, 0, 5
+; CHECK-NEXT:    vrepih %v1, 4
+; CHECK-NEXT:    vperm %v24, %v0, %v0, %v1
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <2 x float> %V to <2 x i8>
+  ret <2 x i8> %Res
+}
+
+define <4 x i8> @fun2(<4 x float> %V) {
+; CHECK-LABEL: fun2:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclfeb %v0, %v24, 0, 5
+; CHECK-NEXT:    larl %r1, .LCPI2_0
+; CHECK-NEXT:    vl %v1, 0(%r1), 3
+; CHECK-NEXT:    vperm %v24, %v0, %v0, %v1
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <4 x float> %V to <4 x i8>
+  ret <4 x i8> %Res
+}
+
+define <8 x i8> @fun3(<8 x float> %V) {
+; CHECK-LABEL: fun3:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclfeb %v0, %v26, 0, 5
+; CHECK-NEXT:    vclfeb %v1, %v24, 0, 5
+; CHECK-NEXT:    larl %r1, .LCPI3_0
+; CHECK-NEXT:    vl %v2, 0(%r1), 3
+; CHECK-NEXT:    vperm %v24, %v1, %v0, %v2
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <8 x float> %V to <8 x i8>
+  ret <8 x i8> %Res
+}
+
+define <16 x i8> @fun4(<16 x float> %V) {
+; CHECK-LABEL: fun4:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclfeb %v0, %v30, 0, 5
+; CHECK-NEXT:    vclfeb %v1, %v28, 0, 5
+; CHECK-NEXT:    vclfeb %v2, %v26, 0, 5
+; CHECK-NEXT:    vclfeb %v3, %v24, 0, 5
+; CHECK-NEXT:    larl %r1, .LCPI4_0
+; CHECK-NEXT:    larl %r2, .LCPI4_1
+; CHECK-NEXT:    vl %v4, 0(%r1), 3
+; CHECK-NEXT:    vl %v5, 0(%r2), 3
+; CHECK-NEXT:    vperm %v0, %v1, %v0, %v4
+; CHECK-NEXT:    vperm %v1, %v3, %v2, %v5
+; CHECK-NEXT:    vpdi %v24, %v1, %v0, 1
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <16 x float> %V to <16 x i8>
+  ret <16 x i8> %Res
+}
+
+define <32 x i8> @fun5(<32 x float> %V) {
+; CHECK-LABEL: fun5:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclfeb %v6, %v30, 0, 5
+; CHECK-NEXT:    vclfeb %v7, %v28, 0, 5
+; CHECK-NEXT:    larl %r1, .LCPI5_0
+; CHECK-NEXT:    vl %v16, 0(%r1), 3
+; CHECK-NEXT:    vclfeb %v0, %v27, 0, 5
+; CHECK-NEXT:    vclfeb %v1, %v25, 0, 5
+; CHECK-NEXT:    vclfeb %v2, %v31, 0, 5
+; CHECK-NEXT:    vclfeb %v3, %v29, 0, 5
+; CHECK-NEXT:    vclfeb %v4, %v26, 0, 5
+; CHECK-NEXT:    vclfeb %v5, %v24, 0, 5
+; CHECK-NEXT:    larl %r1, .LCPI5_1
+; CHECK-NEXT:    vperm %v6, %v7, %v6, %v16
+; CHECK-NEXT:    vl %v7, 0(%r1), 3
+; CHECK-NEXT:    vperm %v4, %v5, %v4, %v7
+; CHECK-NEXT:    vperm %v2, %v3, %v2, %v16
+; CHECK-NEXT:    vperm %v0, %v1, %v0, %v7
+; CHECK-NEXT:    vpdi %v24, %v4, %v6, 1
+; CHECK-NEXT:    vpdi %v26, %v0, %v2, 1
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <32 x float> %V to <32 x i8>
+  ret <32 x i8> %Res
+}
+
+define <1 x i16> @fun6(<1 x float> %V) {
+; CHECK-LABEL: fun6:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclfeb %v24, %v24, 0, 5
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <1 x float> %V to <1 x i16>
+  ret <1 x i16> %Res
+}
+
+define <2 x i16> @fun7(<2 x float> %V) {
+; CHECK-LABEL: fun7:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclfeb %v0, %v24, 0, 5
+; CHECK-NEXT:    larl %r1, .LCPI7_0
+; CHECK-NEXT:    vl %v1, 0(%r1), 3
+; CHECK-NEXT:    vperm %v24, %v0, %v0, %v1
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <2 x float> %V to <2 x i16>
+  ret <2 x i16> %Res
+}
+
+define <4 x i16> @fun8(<4 x float> %V) {
+; CHECK-LABEL: fun8:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclfeb %v0, %v24, 0, 5
+; CHECK-NEXT:    larl %r1, .LCPI8_0
+; CHECK-NEXT:    vl %v1, 0(%r1), 3
+; CHECK-NEXT:    vperm %v24, %v0, %v0, %v1
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <4 x float> %V to <4 x i16>
+  ret <4 x i16> %Res
+}
+
+define <8 x i16> @fun9(<8 x float> %V) {
+; CHECK-LABEL: fun9:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclfeb %v1, %v26, 0, 5
+; CHECK-NEXT:    vclfeb %v2, %v24, 0, 5
+; CHECK-NEXT:    larl %r1, .LCPI9_0
+; CHECK-NEXT:    vl %v0, 0(%r1), 3
+; CHECK-NEXT:    vperm %v24, %v2, %v1, %v0
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <8 x float> %V to <8 x i16>
+  ret <8 x i16> %Res
+}
+
+define <16 x i16> @fun10(<16 x float> %V) {
+; CHECK-LABEL: fun10:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclfeb %v0, %v30, 0, 5
+; CHECK-NEXT:    vclfeb %v1, %v28, 0, 5
+; CHECK-NEXT:    vclfeb %v2, %v26, 0, 5
+; CHECK-NEXT:    vclfeb %v3, %v24, 0, 5
+; CHECK-NEXT:    larl %r1, .LCPI10_0
+; CHECK-NEXT:    vl %v4, 0(%r1), 3
+; CHECK-NEXT:    vperm %v24, %v3, %v2, %v4
+; CHECK-NEXT:    vperm %v26, %v1, %v0, %v4
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <16 x float> %V to <16 x i16>
+  ret <16 x i16> %Res
+}
+
+define <1 x i8> @fun11(<1 x double> %V) {
+; CHECK-LABEL: fun11:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclgdb %v24, %v24, 0, 5
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <1 x double> %V to <1 x i8>
+  ret <1 x i8> %Res
+}
+
+define <2 x i8> @fun12(<2 x double> %V) {
+; CHECK-LABEL: fun12:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclgdb %v0, %v24, 0, 5
+; CHECK-NEXT:    vrepih %v1, 8
+; CHECK-NEXT:    vperm %v24, %v0, %v0, %v1
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <2 x double> %V to <2 x i8>
+  ret <2 x i8> %Res
+}
+
+define <4 x i8> @fun13(<4 x double> %V) {
+; CHECK-LABEL: fun13:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclgdb %v0, %v26, 0, 5
+; CHECK-NEXT:    vclgdb %v1, %v24, 0, 5
+; CHECK-NEXT:    larl %r1, .LCPI13_0
+; CHECK-NEXT:    vl %v2, 0(%r1), 3
+; CHECK-NEXT:    vperm %v24, %v1, %v0, %v2
+; CHECK-NEXT:    br %r14
+  %Res = fptoui <4 x double> %V to <4 x i8>
+  ret <4 x i8> %Res
+}
+
+define <16 x i8> @fun15(<16 x double> %V) {
+; CHECK-LABEL: fun15:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vclgdb %v0, %v31, 0, 5
+; CHECK-NEXT:    vclgdb %v1, %v29, 0, 5
+; CHECK-NEXT:    vclgdb %v2, %v27, 0, 5
+; CHECK-NEXT:    vclgdb %v3, %v25, 0, 5
+; CHECK-NEXT:    vclgdb %v4, %v30, 0, 5
+; CHECK-NEXT:    vclgdb %v5, %v28, 0, 5
+; CHECK-NEXT:    vclgdb %v6, %v26, 0, 5
+; CHECK-NEXT:    vclgdb %v7, %v24, 0, 5
+; CHECK-NEXT:    larl %r1, .LCPI14_0
+; CHECK-NEXT:    larl %r2, .LCPI14_1
+; CHE...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/205311


More information about the llvm-commits mailing list