diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 1d085100dbe..8ab61529057 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -1721,11 +1721,7 @@ public: const ConstantInt *getConstantIntValue() const { return Value; } const APInt &getAPIntValue() const { return Value->getValue(); } uint64_t getZExtValue() const { return Value->getZExtValue(); } - - int64_t getSignExtended() const { - unsigned Bits = getValueType(0).getSizeInBits(); - return ((int64_t)getZExtValue() << (64-Bits)) >> (64-Bits); - } + int64_t getSExtValue() const { return Value->getSExtValue(); } bool isNullValue() const { return Value->isNullValue(); } bool isAllOnesValue() const { return Value->isAllOnesValue(); } diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index ee4c9e639ba..22145122d55 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1170,12 +1170,12 @@ SDValue DAGCombiner::visitMUL(SDNode *N) { DAG.getConstant(N1C->getAPIntValue().logBase2(), TLI.getShiftAmountTy())); // fold (mul x, -(1 << c)) -> -(x << c) or (-x) << c - if (N1C && isPowerOf2_64(-N1C->getSignExtended())) { + if (N1C && isPowerOf2_64(-N1C->getSExtValue())) { // FIXME: If the input is something that is easily negated (e.g. a // single-use add), we should put the negate there. return DAG.getNode(ISD::SUB, VT, DAG.getConstant(0, VT), DAG.getNode(ISD::SHL, VT, N0, - DAG.getConstant(Log2_64(-N1C->getSignExtended()), + DAG.getConstant(Log2_64(-N1C->getSExtValue()), TLI.getShiftAmountTy()))); } @@ -1238,7 +1238,7 @@ SDValue DAGCombiner::visitSDIV(SDNode *N) { if (N0C && N1C && !N1C->isNullValue()) return DAG.FoldConstantArithmetic(ISD::SDIV, VT, N0C, N1C); // fold (sdiv X, 1) -> X - if (N1C && N1C->getSignExtended() == 1LL) + if (N1C && N1C->getSExtValue() == 1LL) return N0; // fold (sdiv X, -1) -> 0-X if (N1C && N1C->isAllOnesValue()) @@ -1251,13 +1251,13 @@ SDValue DAGCombiner::visitSDIV(SDNode *N) { } // fold (sdiv X, pow2) -> simple ops after legalize if (N1C && !N1C->isNullValue() && !TLI.isIntDivCheap() && - (isPowerOf2_64(N1C->getSignExtended()) || - isPowerOf2_64(-N1C->getSignExtended()))) { + (isPowerOf2_64(N1C->getSExtValue()) || + isPowerOf2_64(-N1C->getSExtValue()))) { // If dividing by powers of two is cheap, then don't perform the following // fold. if (TLI.isPow2DivCheap()) return SDValue(); - int64_t pow2 = N1C->getSignExtended(); + int64_t pow2 = N1C->getSExtValue(); int64_t abs2 = pow2 > 0 ? pow2 : -pow2; unsigned lg2 = Log2_64(abs2); // Splat the sign bit into the register @@ -1283,7 +1283,7 @@ SDValue DAGCombiner::visitSDIV(SDNode *N) { } // if integer divide is expensive and we satisfy the requirements, emit an // alternate sequence. - if (N1C && (N1C->getSignExtended() < -1 || N1C->getSignExtended() > 1) && + if (N1C && (N1C->getSExtValue() < -1 || N1C->getSExtValue() > 1) && !TLI.isIntDivCheap()) { SDValue Op = BuildSDIV(N); if (Op.getNode()) return Op; diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp index a9078b1e513..7e17daaa0f6 100644 --- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -1744,13 +1744,13 @@ bool TargetLowering::isGAPlusOffset(SDNode *N, GlobalValue* &GA, if (isGAPlusOffset(N1.getNode(), GA, Offset)) { ConstantSDNode *V = dyn_cast(N2); if (V) { - Offset += V->getSignExtended(); + Offset += V->getSExtValue(); return true; } } else if (isGAPlusOffset(N2.getNode(), GA, Offset)) { ConstantSDNode *V = dyn_cast(N1); if (V) { - Offset += V->getSignExtended(); + Offset += V->getSExtValue(); return true; } } @@ -2298,7 +2298,7 @@ SDValue TargetLowering::BuildSDIV(SDNode *N, SelectionDAG &DAG, if (!isTypeLegal(VT) || (VT != MVT::i32 && VT != MVT::i64)) return SDValue(); // BuildSDIV only operates on i32 or i64 - int64_t d = cast(N->getOperand(1))->getSignExtended(); + int64_t d = cast(N->getOperand(1))->getSExtValue(); ms magics = (VT == MVT::i32) ? magic32(d) : magic64(d); // Multiply the numerator (operand 0) by the magic value diff --git a/lib/Target/CellSPU/SPUISelDAGToDAG.cpp b/lib/Target/CellSPU/SPUISelDAGToDAG.cpp index 7b667ec8ba1..bcdc28cfe9b 100644 --- a/lib/Target/CellSPU/SPUISelDAGToDAG.cpp +++ b/lib/Target/CellSPU/SPUISelDAGToDAG.cpp @@ -41,14 +41,14 @@ namespace { bool isI64IntS10Immediate(ConstantSDNode *CN) { - return isS10Constant(CN->getSignExtended()); + return isS10Constant(CN->getSExtValue()); } //! ConstantSDNode predicate for i32 sign-extended, 10-bit immediates bool isI32IntS10Immediate(ConstantSDNode *CN) { - return isS10Constant(CN->getSignExtended()); + return isS10Constant(CN->getSExtValue()); } #if 0 @@ -65,14 +65,14 @@ namespace { bool isI32IntU10Immediate(ConstantSDNode *CN) { - return isU10Constant(CN->getSignExtended()); + return isU10Constant(CN->getSExtValue()); } //! ConstantSDNode predicate for i16 sign-extended, 10-bit immediate values bool isI16IntS10Immediate(ConstantSDNode *CN) { - return isS10Constant(CN->getSignExtended()); + return isS10Constant(CN->getSExtValue()); } //! SDNode predicate for i16 sign-extended, 10-bit immediate values @@ -468,7 +468,7 @@ SPUDAGToDAGISel::DFormAddressPredicate(SDValue Op, SDValue N, SDValue &Base, } else if (Op1.getOpcode() == ISD::Constant || Op1.getOpcode() == ISD::TargetConstant) { ConstantSDNode *CN = dyn_cast(Op1); - int32_t offset = int32_t(CN->getSignExtended()); + int32_t offset = int32_t(CN->getSExtValue()); if (Op0.getOpcode() == ISD::FrameIndex) { FrameIndexSDNode *FIN = dyn_cast(Op0); @@ -489,7 +489,7 @@ SPUDAGToDAGISel::DFormAddressPredicate(SDValue Op, SDValue N, SDValue &Base, } else if (Op0.getOpcode() == ISD::Constant || Op0.getOpcode() == ISD::TargetConstant) { ConstantSDNode *CN = dyn_cast(Op0); - int32_t offset = int32_t(CN->getSignExtended()); + int32_t offset = int32_t(CN->getSExtValue()); if (Op1.getOpcode() == ISD::FrameIndex) { FrameIndexSDNode *FIN = dyn_cast(Op1); @@ -525,11 +525,11 @@ SPUDAGToDAGISel::DFormAddressPredicate(SDValue Op, SDValue N, SDValue &Base, if (isa(Op1)) { ConstantSDNode *CN = cast(Op1); - offset = int32_t(CN->getSignExtended()); + offset = int32_t(CN->getSExtValue()); idxOp = Op0; } else if (isa(Op0)) { ConstantSDNode *CN = cast(Op0); - offset = int32_t(CN->getSignExtended()); + offset = int32_t(CN->getSExtValue()); idxOp = Op1; } diff --git a/lib/Target/CellSPU/SPUISelLowering.cpp b/lib/Target/CellSPU/SPUISelLowering.cpp index 285c5b6f1e6..474fbc383d0 100644 --- a/lib/Target/CellSPU/SPUISelLowering.cpp +++ b/lib/Target/CellSPU/SPUISelLowering.cpp @@ -1392,7 +1392,7 @@ SDValue SPU::get_vec_u18imm(SDNode *N, SelectionDAG &DAG, SDValue SPU::get_vec_i16imm(SDNode *N, SelectionDAG &DAG, MVT ValueType) { if (ConstantSDNode *CN = getVecImm(N)) { - int64_t Value = CN->getSignExtended(); + int64_t Value = CN->getSExtValue(); if (ValueType == MVT::i64) { uint64_t UValue = CN->getZExtValue(); uint32_t upper = uint32_t(UValue >> 32); @@ -1415,7 +1415,7 @@ SDValue SPU::get_vec_i16imm(SDNode *N, SelectionDAG &DAG, SDValue SPU::get_vec_i10imm(SDNode *N, SelectionDAG &DAG, MVT ValueType) { if (ConstantSDNode *CN = getVecImm(N)) { - int64_t Value = CN->getSignExtended(); + int64_t Value = CN->getSExtValue(); if (ValueType == MVT::i64) { uint64_t UValue = CN->getZExtValue(); uint32_t upper = uint32_t(UValue >> 32); diff --git a/lib/Target/CellSPU/SPUOperands.td b/lib/Target/CellSPU/SPUOperands.td index 9a53cbe071e..43982279b52 100644 --- a/lib/Target/CellSPU/SPUOperands.td +++ b/lib/Target/CellSPU/SPUOperands.td @@ -65,7 +65,7 @@ def HI16_vec : SDNodeXFormgetSignExtended()); + int sextVal = int(N->getSExtValue()); return (sextVal >= -64 && sextVal <= 63); }]>; @@ -78,7 +78,7 @@ def uimm7: PatLeaf<(imm), [{ // immSExt8 predicate - True if the immediate fits in an 8-bit sign extended // field. def immSExt8 : PatLeaf<(imm), [{ - int Value = int(N->getSignExtended()); + int Value = int(N->getSExtValue()); return (Value >= -(1 << 8) && Value <= (1 << 8) - 1); }]>; diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp index ee6fb6ed829..a240a15e6a7 100644 --- a/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/lib/Target/PowerPC/PPCISelLowering.cpp @@ -664,7 +664,7 @@ SDValue PPC::get_VSPLTI_elt(SDNode *N, unsigned ByteSize, SelectionDAG &DAG) { if (LeadingOnes) { if (UniquedVals[Multiple-1].getNode() == 0) return DAG.getTargetConstant(~0U, MVT::i32); // -1,-1,-1,undef - int Val =cast(UniquedVals[Multiple-1])->getSignExtended(); + int Val =cast(UniquedVals[Multiple-1])->getSExtValue(); if (Val >= -16) // -1,-1,-1,-2 -> vspltisw(-2) return DAG.getTargetConstant(Val, MVT::i32); } diff --git a/lib/Target/X86/X86ISelDAGToDAG.cpp b/lib/Target/X86/X86ISelDAGToDAG.cpp index 9fe19ab67d3..56bffaba31c 100644 --- a/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -775,7 +775,7 @@ bool X86DAGToDAGISel::MatchAddress(SDValue N, X86ISelAddressMode &AM, // RIP relative addressing: %rip + 32-bit displacement! if (AM.isRIPRel) { if (!AM.ES && AM.JT != -1 && N.getOpcode() == ISD::Constant) { - int64_t Val = cast(N)->getSignExtended(); + int64_t Val = cast(N)->getSExtValue(); if (isInt32(AM.Disp + Val)) { AM.Disp += Val; return false; @@ -790,7 +790,7 @@ bool X86DAGToDAGISel::MatchAddress(SDValue N, X86ISelAddressMode &AM, switch (N.getOpcode()) { default: break; case ISD::Constant: { - int64_t Val = cast(N)->getSignExtended(); + int64_t Val = cast(N)->getSExtValue(); if (isInt32(AM.Disp + Val)) { AM.Disp += Val; return false; @@ -952,7 +952,7 @@ DOUT << "AlreadySelected " << AlreadySelected << "\n"; // Address could not have picked a GV address for the displacement. AM.GV == NULL && // On x86-64, the resultant disp must fit in 32-bits. - isInt32(AM.Disp + CN->getSignExtended()) && + isInt32(AM.Disp + CN->getSExtValue()) && // Check to see if the LHS & C is zero. CurDAG->MaskedValueIsZero(N.getOperand(0), CN->getAPIntValue())) { AM.Disp += CN->getZExtValue(); diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index d8d5db92a03..1ef644d54d8 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -5019,7 +5019,7 @@ SDValue X86TargetLowering::LowerSELECT(SDValue Op, SelectionDAG &DAG) { bool IllegalFPCMov = false; if (VT.isFloatingPoint() && !VT.isVector() && !isScalarFPTypeInSSEReg(VT)) // FPStack? - IllegalFPCMov = !hasFPCMov(cast(CC)->getSignExtended()); + IllegalFPCMov = !hasFPCMov(cast(CC)->getSExtValue()); if ((Opc == X86ISD::CMP || Opc == X86ISD::COMI || diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index e4a3f098d35..44b6d75c0f7 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -437,7 +437,7 @@ public: if (N->isLeaf()) { if (IntInit *II = dynamic_cast(N->getLeafValue())) { emitCheck("cast(" + RootName + - ")->getSignExtended() == " + itostr(II->getValue())); + ")->getSExtValue() == " + itostr(II->getValue())); return; } else if (!NodeIsComplexPattern(N)) { assert(0 && "Cannot match this as a leaf value!"); @@ -726,7 +726,7 @@ public: emitCheck("isa(" + RootName + ")"); unsigned CTmp = TmpNo++; emitCode("int64_t CN"+utostr(CTmp)+" = cast("+ - RootName + ")->getSignExtended();"); + RootName + ")->getSExtValue();"); emitCheck("CN" + utostr(CTmp) + " == " +itostr(II->getValue())); } else {