From 7ceef03dc952a8ad09c055c21d613a0ff30f27d8 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 27 Nov 2018 18:24:56 +0000 Subject: [PATCH] [X86] Replace an APInt that is guaranteed to be 8-bits with just an 'unsigned' We're already mixing this APInt with other 'unsigned' variables. This allows us to use regular comparison operators instead of needing to use APInt::ult or APInt::uge. And it removes a later conversion from APInt to unsigned. I might be adding another combine to this function and this will probably simplify the logic required for that. llvm-svn: 347684 --- llvm/lib/Target/X86/X86ISelLowering.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 1a1cda923d85..c33394f439d0 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -35429,11 +35429,12 @@ static SDValue combineVectorShiftImm(SDNode *N, SelectionDAG &DAG, unsigned NumBitsPerElt = VT.getScalarSizeInBits(); assert(VT == N0.getValueType() && (NumBitsPerElt % 8) == 0 && "Unexpected value type"); + assert(N1.getValueType() == MVT::i8 && "Unexpected shift amount type"); // Out of range logical bit shifts are guaranteed to be zero. // Out of range arithmetic bit shifts splat the sign bit. - APInt ShiftVal = cast(N1)->getAPIntValue(); - if (ShiftVal.zextOrTrunc(8).uge(NumBitsPerElt)) { + unsigned ShiftVal = cast(N1)->getZExtValue(); + if (ShiftVal >= NumBitsPerElt) { if (LogicalShift) return DAG.getConstant(0, SDLoc(N), VT); else @@ -35460,12 +35461,12 @@ static SDValue combineVectorShiftImm(SDNode *N, SelectionDAG &DAG, N1 == N0.getOperand(1)) { SDValue N00 = N0.getOperand(0); unsigned NumSignBits = DAG.ComputeNumSignBits(N00); - if (ShiftVal.ult(NumSignBits)) + if (ShiftVal < NumSignBits) return N00; } // We can decode 'whole byte' logical bit shifts as shuffles. - if (LogicalShift && (ShiftVal.getZExtValue() % 8) == 0) { + if (LogicalShift && (ShiftVal % 8) == 0) { SDValue Op(N, 0); if (SDValue Res = combineX86ShufflesRecursively( {Op}, 0, Op, {0}, {}, /*Depth*/ 1, @@ -35480,14 +35481,13 @@ static SDValue combineVectorShiftImm(SDNode *N, SelectionDAG &DAG, getTargetConstantBitsFromNode(N0, NumBitsPerElt, UndefElts, EltBits)) { assert(EltBits.size() == VT.getVectorNumElements() && "Unexpected shift value type"); - unsigned ShiftImm = ShiftVal.getZExtValue(); for (APInt &Elt : EltBits) { if (X86ISD::VSHLI == Opcode) - Elt <<= ShiftImm; + Elt <<= ShiftVal; else if (X86ISD::VSRAI == Opcode) - Elt.ashrInPlace(ShiftImm); + Elt.ashrInPlace(ShiftVal); else - Elt.lshrInPlace(ShiftImm); + Elt.lshrInPlace(ShiftVal); } return getConstVector(EltBits, UndefElts, VT.getSimpleVT(), DAG, SDLoc(N)); }