Skip to content

Commit b01c15b

Browse files
committed
Add comment that shift amt will be clamped and apply clang-format
Signed-off-by: John Lu <[email protected]>
1 parent 367846d commit b01c15b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4050,19 +4050,24 @@ SDValue AMDGPUTargetLowering::performShlCombine(SDNode *N,
40504050
// shl i64 X, Y -> [0, shl i32 X, (Y & 0x1F)]
40514051
if (VT == MVT::i64) {
40524052
KnownBits Known = DAG.computeKnownBits(RHS);
4053-
EVT TargetType=VT.getHalfSizedIntegerVT(*DAG.getContext());
4054-
EVT TargetVecPairType=EVT::getVectorVT(*DAG.getContext(), TargetType, 2);
4053+
EVT TargetType = VT.getHalfSizedIntegerVT(*DAG.getContext());
4054+
EVT TargetVecPairType =
4055+
EVT::getVectorVT(*DAG.getContext(), TargetType, 2);
40554056

40564057
if (Known.getMinValue().getZExtValue() >= TargetType.getSizeInBits()) {
40574058
SDValue truncShiftAmt = DAG.getNode(ISD::TRUNCATE, SL, TargetType, RHS);
4058-
const SDValue ShiftMask = DAG.getConstant(TargetType.getSizeInBits() - 1, SL, TargetType);
4059-
// This AND instruction will be removed during later instruction selection.
4059+
const SDValue ShiftMask =
4060+
DAG.getConstant(TargetType.getSizeInBits() - 1, SL, TargetType);
4061+
// This AND instruction will clamp out of bounds shift values.
4062+
// It will also be removed during later instruction selection.
40604063
SDValue MaskedShiftAmt =
40614064
DAG.getNode(ISD::AND, SL, TargetType, truncShiftAmt, ShiftMask);
40624065
SDValue Lo = DAG.getNode(ISD::TRUNCATE, SL, TargetType, LHS);
4063-
SDValue NewShift = DAG.getNode(ISD::SHL, SL, TargetType, Lo, MaskedShiftAmt, N->getFlags());
4066+
SDValue NewShift = DAG.getNode(ISD::SHL, SL, TargetType, Lo,
4067+
MaskedShiftAmt, N->getFlags());
40644068
const SDValue Zero = DAG.getConstant(0, SL, TargetType);
4065-
SDValue Vec = DAG.getBuildVector(TargetVecPairType, SL, {Zero, NewShift});
4069+
SDValue Vec =
4070+
DAG.getBuildVector(TargetVecPairType, SL, {Zero, NewShift});
40664071
return DAG.getNode(ISD::BITCAST, SL, VT, Vec);
40674072
}
40684073
}

0 commit comments

Comments
 (0)