[DAGCombiner] Refactor code in visitShiftByConstant slightly to make it more readable. NFC

This changes the isShift variable to include the constant operand
check that was previously in the if statement.

While there fix an 80 column violation and an unnecessary use of
getNode. Also fix variable name capitalization.

llvm-svn: 361168
This commit is contained in:
Craig Topper 2019-05-20 16:26:55 +00:00
parent 5239298b0d
commit 203bfdd0f0
1 changed files with 11 additions and 10 deletions

View File

@ -6618,19 +6618,20 @@ SDValue DAGCombiner::visitShiftByConstant(SDNode *N, ConstantSDNode *Amt) {
return SDValue(); return SDValue();
// FIXME: disable this unless the input to the binop is a shift by a constant // FIXME: disable this unless the input to the binop is a shift by a constant
// or is copy/select.Enable this in other cases when figure out it's exactly profitable. // or is copy/select. Enable this in other cases when figure out it's exactly
SDNode *BinOpLHSVal = LHS->getOperand(0).getNode(); // profitable.
bool isShift = BinOpLHSVal->getOpcode() == ISD::SHL || SDValue BinOpLHSVal = LHS->getOperand(0);
BinOpLHSVal->getOpcode() == ISD::SRA || bool IsShiftByConstant = (BinOpLHSVal.getOpcode() == ISD::SHL ||
BinOpLHSVal->getOpcode() == ISD::SRL; BinOpLHSVal.getOpcode() == ISD::SRA ||
bool isCopyOrSelect = BinOpLHSVal->getOpcode() == ISD::CopyFromReg || BinOpLHSVal.getOpcode() == ISD::SRL) &&
BinOpLHSVal->getOpcode() == ISD::SELECT; isa<ConstantSDNode>(BinOpLHSVal.getOperand(1));
bool IsCopyOrSelect = BinOpLHSVal.getOpcode() == ISD::CopyFromReg ||
BinOpLHSVal.getOpcode() == ISD::SELECT;
if ((!isShift || !isa<ConstantSDNode>(BinOpLHSVal->getOperand(1))) && if (!IsShiftByConstant && !IsCopyOrSelect)
!isCopyOrSelect)
return SDValue(); return SDValue();
if (isCopyOrSelect && N->hasOneUse()) if (IsCopyOrSelect && N->hasOneUse())
return SDValue(); return SDValue();
EVT VT = N->getValueType(0); EVT VT = N->getValueType(0);