summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
diff options
context:
space:
mode:
authorMingming Liu <mingmingl@google.com>2025-09-10 15:25:31 -0700
committerGitHub <noreply@github.com>2025-09-10 15:25:31 -0700
commit1417dafa1db9cb1b2b09438aa9f53ea5ab6e36e2 (patch)
tree57f4b1f313c8cf74eed8819870f39c36ea263c68 /llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
parent898b813bc8a6d0276bf0f4769f5f2f64b34e632d (diff)
parentb8cefcb601ddaa18482555c4ff363c01a270c2fe (diff)
Merge branch 'main' into users/mingmingl-llvm/samplefdo-profile-formatusers/mingmingl-llvm/samplefdo-profile-format
Diffstat (limited to 'llvm/lib/Target/SystemZ/SystemZISelLowering.cpp')
-rw-r--r--llvm/lib/Target/SystemZ/SystemZISelLowering.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index c73dc3021eb4..3b7d11a318dc 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -287,6 +287,9 @@ SystemZTargetLowering::SystemZTargetLowering(const TargetMachine &TM,
// Additional instructions available with z17.
if (Subtarget.hasVectorEnhancements3()) {
setOperationAction(ISD::ABS, MVT::i128, Legal);
+
+ setOperationAction({ISD::SMIN, ISD::UMIN, ISD::SMAX, ISD::UMAX},
+ MVT::i128, Legal);
}
}
@@ -492,6 +495,9 @@ SystemZTargetLowering::SystemZTargetLowering(const TargetMachine &TM,
// Map SETCCs onto one of VCE, VCH or VCHL, swapping the operands
// and inverting the result as necessary.
setOperationAction(ISD::SETCC, VT, Custom);
+
+ setOperationAction({ISD::SMIN, ISD::UMIN, ISD::SMAX, ISD::UMAX}, VT,
+ Legal);
}
}
@@ -6719,6 +6725,14 @@ SDValue SystemZTargetLowering::lowerFSHL(SDValue Op, SelectionDAG &DAG) const {
if ((ShiftAmt & 7) == 0 || Subtarget.hasVectorEnhancements2()) {
SDValue Op0 = DAG.getBitcast(MVT::v16i8, Op.getOperand(0));
SDValue Op1 = DAG.getBitcast(MVT::v16i8, Op.getOperand(1));
+ if (ShiftAmt > 120) {
+ // For N in 121..128, fshl N == fshr (128 - N), and for 1 <= N < 8
+ // SHR_DOUBLE_BIT emits fewer instructions.
+ SDValue Val =
+ DAG.getNode(SystemZISD::SHR_DOUBLE_BIT, DL, MVT::v16i8, Op0, Op1,
+ DAG.getTargetConstant(128 - ShiftAmt, DL, MVT::i32));
+ return DAG.getBitcast(MVT::i128, Val);
+ }
SmallVector<int, 16> Mask(16);
for (unsigned Elt = 0; Elt < 16; Elt++)
Mask[Elt] = (ShiftAmt >> 3) + Elt;
@@ -6742,13 +6756,21 @@ SDValue SystemZTargetLowering::lowerFSHR(SDValue Op, SelectionDAG &DAG) const {
// i128 FSHR with a constant amount that is a multiple of 8 can be
// implemented via VECTOR_SHUFFLE. If we have the vector-enhancements-2
// facility, FSHR with a constant amount less than 8 can be implemented
- // via SHL_DOUBLE_BIT, and FSHR with other constant amounts by a
+ // via SHR_DOUBLE_BIT, and FSHR with other constant amounts by a
// combination of the two.
if (auto *ShiftAmtNode = dyn_cast<ConstantSDNode>(Op.getOperand(2))) {
uint64_t ShiftAmt = ShiftAmtNode->getZExtValue() & 127;
if ((ShiftAmt & 7) == 0 || Subtarget.hasVectorEnhancements2()) {
SDValue Op0 = DAG.getBitcast(MVT::v16i8, Op.getOperand(0));
SDValue Op1 = DAG.getBitcast(MVT::v16i8, Op.getOperand(1));
+ if (ShiftAmt > 120) {
+ // For N in 121..128, fshr N == fshl (128 - N), and for 1 <= N < 8
+ // SHL_DOUBLE_BIT emits fewer instructions.
+ SDValue Val =
+ DAG.getNode(SystemZISD::SHL_DOUBLE_BIT, DL, MVT::v16i8, Op0, Op1,
+ DAG.getTargetConstant(128 - ShiftAmt, DL, MVT::i32));
+ return DAG.getBitcast(MVT::i128, Val);
+ }
SmallVector<int, 16> Mask(16);
for (unsigned Elt = 0; Elt < 16; Elt++)
Mask[Elt] = 16 - (ShiftAmt >> 3) + Elt;