Skip to content

Commit d574bec

Browse files
Prefer early return
1 parent 0ffe613 commit d574bec

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5620,28 +5620,28 @@ static SDValue PerformTruncCombine(SDNode *N,
56205620
case ISD::XOR: {
56215621
EVT VT = N->getValueType(0);
56225622
EVT LogicalVT = LogicalOp.getValueType();
5623-
if (VT == MVT::i32 && LogicalVT == MVT::i64) {
5624-
const TargetLowering &TLI = DCI.DAG.getTargetLoweringInfo();
5625-
if (VT.isScalarInteger() ||
5626-
TLI.isOperationLegal(LogicalOp.getOpcode(), VT)) {
5627-
if (all_of(LogicalOp.getNode()->uses(), [](SDNode *U) {
5628-
return U->isMachineOpcode()
5629-
? U->getMachineOpcode() == NVPTX::CVT_u32_u64
5630-
: U->getOpcode() == ISD::TRUNCATE;
5631-
})) {
5632-
SDLoc DL(N);
5633-
SDValue None =
5634-
DCI.DAG.getTargetConstant(NVPTX::PTXCvtMode::NONE, DL, MVT::i32);
5635-
SDNode *NarrowL = DCI.DAG.getMachineNode(
5636-
NVPTX::CVT_u32_u64, DL, VT, LogicalOp.getOperand(0), None);
5637-
SDNode *NarrowR = DCI.DAG.getMachineNode(
5638-
NVPTX::CVT_u32_u64, DL, VT, LogicalOp.getOperand(1), None);
5639-
return DCI.DAG.getNode(LogicalOp.getOpcode(), DL, VT,
5640-
SDValue(NarrowL, 0), SDValue(NarrowR, 0));
5641-
}
5642-
}
5643-
}
5644-
break;
5623+
if (VT != MVT::i32 || LogicalVT != MVT::i64)
5624+
break;
5625+
const TargetLowering &TLI = DCI.DAG.getTargetLoweringInfo();
5626+
if (!VT.isScalarInteger() &&
5627+
!TLI.isOperationLegal(LogicalOp.getOpcode(), VT))
5628+
break;
5629+
if (!all_of(LogicalOp.getNode()->uses(), [](SDNode *U) {
5630+
return U->isMachineOpcode()
5631+
? U->getMachineOpcode() == NVPTX::CVT_u32_u64
5632+
: U->getOpcode() == ISD::TRUNCATE;
5633+
}))
5634+
break;
5635+
5636+
SDLoc DL(N);
5637+
SDValue CVTNone =
5638+
DCI.DAG.getTargetConstant(NVPTX::PTXCvtMode::NONE, DL, MVT::i32);
5639+
SDNode *NarrowL = DCI.DAG.getMachineNode(
5640+
NVPTX::CVT_u32_u64, DL, VT, LogicalOp.getOperand(0), CVTNone);
5641+
SDNode *NarrowR = DCI.DAG.getMachineNode(
5642+
NVPTX::CVT_u32_u64, DL, VT, LogicalOp.getOperand(1), CVTNone);
5643+
return DCI.DAG.getNode(LogicalOp.getOpcode(), DL, VT,
5644+
SDValue(NarrowL, 0), SDValue(NarrowR, 0));
56455645
}
56465646
}
56475647

0 commit comments

Comments
 (0)