[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp
Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.353 - 1.354 --- Log message: make use of helper functions in CCState for analyzing formals and calls. --- Diffs of the changes: (+15 -49) X86ISelLowering.cpp | 64 1 files changed, 15 insertions(+), 49 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.353 llvm/lib/Target/X86/X86ISelLowering.cpp:1.354 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.353 Wed Feb 28 00:26:33 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Wed Feb 28 01:00:42 2007 @@ -609,17 +609,12 @@ SDOperand Root = Op.getOperand(0); bool isVarArg = castConstantSDNode(Op.getOperand(2))-getValue() != 0; + // Assign locations to all of the incoming arguments. SmallVectorCCValAssign, 16 ArgLocs; CCState CCInfo(MF.getFunction()-getCallingConv(), getTargetMachine(), ArgLocs); - - for (unsigned i = 0; i != NumArgs; ++i) { -MVT::ValueType ArgVT = Op.getValue(i).getValueType(); -unsigned ArgFlags = castConstantSDNode(Op.getOperand(3+i))-getValue(); -if (CC_X86_32_C(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, CCInfo)) - assert(0 Unhandled argument type!); - } - + CCInfo.AnalyzeFormalArguments(Op.Val, CC_X86_32_C); + SmallVectorSDOperand, 8 ArgValues; unsigned LastVal = ~0U; for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) { @@ -708,15 +703,10 @@ SDOperand Callee= Op.getOperand(4); unsigned NumOps = (Op.getNumOperands() - 5) / 2; + // Analyze operands of the call, assigning locations to each operand. SmallVectorCCValAssign, 16 ArgLocs; CCState CCInfo(CC, getTargetMachine(), ArgLocs); - - for (unsigned i = 0; i != NumOps; ++i) { -MVT::ValueType ArgVT = Op.getOperand(5+2*i).getValueType(); -unsigned ArgFlags =castConstantSDNode(Op.getOperand(5+2*i+1))-getValue(); -if (CC_X86_32_C(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, CCInfo)) - assert(0 Unhandled argument type!); - } + CCInfo.AnalyzeCallOperands(Op.Val, CC_X86_32_C); // Get a count of how many bytes are to be pushed on the stack. unsigned NumBytes = CCInfo.getNextStackOffset(); @@ -865,21 +855,15 @@ // reasons. SDOperand X86TargetLowering::LowerFastCCArguments(SDOperand Op, SelectionDAG DAG) { - unsigned NumArgs = Op.Val-getNumValues()-1; MachineFunction MF = DAG.getMachineFunction(); MachineFrameInfo *MFI = MF.getFrameInfo(); SDOperand Root = Op.getOperand(0); + // Assign locations to all of the incoming arguments. SmallVectorCCValAssign, 16 ArgLocs; CCState CCInfo(MF.getFunction()-getCallingConv(), getTargetMachine(), ArgLocs); - - for (unsigned i = 0; i != NumArgs; ++i) { -MVT::ValueType ArgVT = Op.getValue(i).getValueType(); -unsigned ArgFlags = castConstantSDNode(Op.getOperand(3+i))-getValue(); -if (CC_X86_32_FastCall(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags,CCInfo)) - assert(0 Unhandled argument type!); - } + CCInfo.AnalyzeFormalArguments(Op.Val, CC_X86_32_FastCall); SmallVectorSDOperand, 8 ArgValues; unsigned LastVal = ~0U; @@ -956,18 +940,11 @@ SDOperand Chain = Op.getOperand(0); bool isTailCall = castConstantSDNode(Op.getOperand(3))-getValue() != 0; SDOperand Callee= Op.getOperand(4); - unsigned NumOps = (Op.getNumOperands() - 5) / 2; - + // Analyze operands of the call, assigning locations to each operand. SmallVectorCCValAssign, 16 ArgLocs; CCState CCInfo(CC, getTargetMachine(), ArgLocs); - - for (unsigned i = 0; i != NumOps; ++i) { -MVT::ValueType ArgVT = Op.getOperand(5+2*i).getValueType(); -unsigned ArgFlags =castConstantSDNode(Op.getOperand(5+2*i+1))-getValue(); -if (CC_X86_32_C(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, CCInfo)) - assert(0 Unhandled argument type!); - } + CCInfo.AnalyzeCallOperands(Op.Val, CC_X86_32_FastCall); // Get a count of how many bytes are to be pushed on the stack. unsigned NumBytes = CCInfo.getNextStackOffset(); @@ -1098,7 +1075,6 @@ SDOperand X86TargetLowering::LowerX86_64CCCArguments(SDOperand Op, SelectionDAG DAG) { - unsigned NumArgs = Op.Val-getNumValues() - 1; MachineFunction MF = DAG.getMachineFunction(); MachineFrameInfo *MFI = MF.getFrameInfo(); SDOperand Root = Op.getOperand(0); @@ -1112,16 +1088,12 @@ X86::XMM4, X86::XMM5, X86::XMM6, X86::XMM7 }; + + // Assign locations to all of the incoming arguments. SmallVectorCCValAssign, 16 ArgLocs; CCState CCInfo(MF.getFunction()-getCallingConv(), getTargetMachine(), ArgLocs); - - for (unsigned i = 0; i != NumArgs; ++i) { -MVT::ValueType ArgVT = Op.getValue(i).getValueType(); -unsigned ArgFlags = castConstantSDNode(Op.getOperand(3+i))-getValue(); -if (CC_X86_64_C(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, CCInfo)) - assert(0 Unhandled
[llvm-commits] CVS: llvm/lib/CodeGen/MachOWriter.cpp
Changes in directory llvm/lib/CodeGen: MachOWriter.cpp updated: 1.29 - 1.30 --- Log message: Fix a typo, thanks Bill! --- Diffs of the changes: (+1 -1) MachOWriter.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/CodeGen/MachOWriter.cpp diff -u llvm/lib/CodeGen/MachOWriter.cpp:1.29 llvm/lib/CodeGen/MachOWriter.cpp:1.30 --- llvm/lib/CodeGen/MachOWriter.cpp:1.29 Wed Feb 28 01:40:50 2007 +++ llvm/lib/CodeGen/MachOWriter.cppWed Feb 28 03:16:38 2007 @@ -107,7 +107,7 @@ virtual intptr_t getConstantPoolEntryAddress(unsigned Index) const { assert(CPLocations.size() Index CP not emitted!); - return CPLocations[Index];\ + return CPLocations[Index]; } virtual intptr_t getJumpTableEntryAddress(unsigned Index) const { assert(JTLocations.size() Index JT not emitted!); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] llvm-gcc: check that fields are laid out in ConvertRecordCONSTRUCTOR
Die obviously, rather than obscurely deep down in make_decl_llvm. I hit this with the Ada f-e: it was replacing fields in a record type without updating constructors, with the result that the constructor element fields did not belong to the constructor type, and thus were not laid out when the type was. Ciao, Duncan. Index: gcc.llvm.master/gcc/llvm-convert.cpp === --- gcc.llvm.master.orig/gcc/llvm-convert.cpp 2007-02-28 11:00:24.0 +0100 +++ gcc.llvm.master/gcc/llvm-convert.cpp 2007-02-28 11:00:48.0 +0100 @@ -5110,6 +5110,7 @@ ProcessBitFieldInitialization(Field, Val, STy, ResultElts); } else { // If not, things are much simpler. + assert(DECL_LLVM_SET_P(Field) Struct not laid out for LLVM?); unsigned FieldNo = castConstantInt(DECL_LLVM(Field))-getZExtValue(); // If this is an initialization of a global that ends with a variable ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] llvm-gcc: only call rest_of_decl_compilation on VAR_DECLs in EmitBIND_EXPR
The variable expansion part of EmitBIND_EXPR is clearly based on expand_var in expr.c, however unlike expand_var it doesn't check for VAR_DECL before calling rest_of_decl_compilation. This patch adds the check. Without it, the Ada run-time fails to build due to rest_of_decl_compilation getting called for a static CONSTANT_DECL. Ciao, Duncan. Index: gcc.llvm.master/gcc/llvm-convert.cpp === --- gcc.llvm.master.orig/gcc/llvm-convert.cpp 2007-02-28 11:52:22.0 +0100 +++ gcc.llvm.master/gcc/llvm-convert.cpp 2007-02-28 12:01:19.0 +0100 @@ -1399,7 +1399,8 @@ tree RealVar = DECL_ORIGIN(Var); // If we haven't already emitted the var, do so now. - if (!TREE_ASM_WRITTEN(RealVar) !lang_hooks.expand_decl(RealVar)) + if (!TREE_ASM_WRITTEN(RealVar) !lang_hooks.expand_decl(RealVar) + TREE_CODE (Var) == VAR_DECL) rest_of_decl_compilation(RealVar, 0, 0); continue; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] ConstantRange
Chris, I have converted ConstantRange to use APInt internally. This simplified it and got rid of some of the helper functions inside ConstantRange (because they have equivalents in APInt). Now I'm thinking that ConstantRange should completely avoid the use of ConstantInt in its API and replace all such uses with APInt. This would mean that the class could be implemented in lib/Support instead of lib/Analysis because it would no longer depend on lib/VMCore. Is this a desirable change? Or, do you want the interface to still work with ConstantInt? Reid. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h
Changes in directory llvm/include/llvm/ADT: APInt.h updated: 1.29 - 1.30 --- Log message: Make APInt a little more friendly to its users: * Add support for + and - of a uint64_t. * Make trunc/sext/zext return *this so it can be chained with other ops * Add smin, smax, umin, umax functions for getting min/max values. --- Diffs of the changes: (+30 -3) APInt.h | 33 ++--- 1 files changed, 30 insertions(+), 3 deletions(-) Index: llvm/include/llvm/ADT/APInt.h diff -u llvm/include/llvm/ADT/APInt.h:1.29 llvm/include/llvm/ADT/APInt.h:1.30 --- llvm/include/llvm/ADT/APInt.h:1.29 Tue Feb 27 20:20:49 2007 +++ llvm/include/llvm/ADT/APInt.h Wed Feb 28 11:33:36 2007 @@ -268,10 +268,17 @@ /// Adds this APInt by the given APInt RHS. /// @brief Addition operator. APInt operator+(const APInt RHS) const; + APInt operator+(uint64_t RHS) const { +return (*this) + APInt(BitWidth, RHS); + } + /// Subtracts this APInt by the given APInt RHS /// @brief Subtraction operator. APInt operator-(const APInt RHS) const; + APInt operator-(uint64_t RHS) const { +return (*this) - APInt(BitWidth, RHS); + } /// @brief Unary negation operator inline APInt operator-() const { @@ -401,20 +408,20 @@ /// Truncate the APInt to a specified width. It is an error to specify a width /// that is greater than or equal to the current width. /// @brief Truncate to new width. - void trunc(uint32_t width); + APInt trunc(uint32_t width); /// This operation sign extends the APInt to a new width. If the high order /// bit is set, the fill on the left will be done with 1 bits, otherwise zero. /// It is an error to specify a width that is less than or equal to the /// current width. /// @brief Sign extend to a new width. - void sext(uint32_t width); + APInt sext(uint32_t width); /// This operation zero extends the APInt to a new width. Thie high order bits /// are filled with 0 bits. It is an error to specify a width that is less /// than or equal to the current width. /// @brief Zero extend to a new width. - void zext(uint32_t width); + APInt zext(uint32_t width); /// @brief Set every bit to 1. APInt set(); @@ -691,6 +698,26 @@ namespace APIntOps { +/// @brief Determine the smaller of two APInts considered to be signed. +inline APInt smin(const APInt A, const APInt B) { + return A.slt(B) ? A : B; +} + +/// @brief Determine the larger of two APInts considered to be signed. +inline APInt smax(const APInt A, const APInt B) { + return A.sgt(B) ? A : B; +} + +/// @brief Determine the smaller of two APInts considered to be signed. +inline APInt umin(const APInt A, const APInt B) { + return A.ult(B) ? A : B; +} + +/// @brief Determine the larger of two APInts considered to be unsigned. +inline APInt umax(const APInt A, const APInt B) { + return A.ugt(B) ? A : B; +} + /// @brief Check if the specified APInt has a N-bits integer value. inline bool isIntN(uint32_t N, const APInt APIVal) { return APIVal.isIntN(N); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Support/APInt.cpp
Changes in directory llvm/lib/Support: APInt.cpp updated: 1.58 - 1.59 --- Log message: Make the trunc/sext/zext methods return APInt so that these operations can be chained together with other operations. --- Diffs of the changes: (+8 -7) APInt.cpp | 15 --- 1 files changed, 8 insertions(+), 7 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.58 llvm/lib/Support/APInt.cpp:1.59 --- llvm/lib/Support/APInt.cpp:1.58 Tue Feb 27 19:30:08 2007 +++ llvm/lib/Support/APInt.cpp Wed Feb 28 11:34:32 2007 @@ -896,7 +896,7 @@ } // Truncate to new width. -void APInt::trunc(uint32_t width) { +APInt APInt::trunc(uint32_t width) { assert(width BitWidth Invalid APInt Truncate request); assert(width = IntegerType::MIN_INT_BITS Can't truncate to 0 bits); uint32_t wordsBefore = getNumWords(); @@ -915,17 +915,17 @@ pVal = newVal; } } - clearUnusedBits(); + return clearUnusedBits(); } // Sign extend to a new width. -void APInt::sext(uint32_t width) { +APInt APInt::sext(uint32_t width) { assert(width BitWidth Invalid APInt SignExtend request); assert(width = IntegerType::MAX_INT_BITS Too many bits); // If the sign bit isn't set, this is the same as zext. if (!isNegative()) { zext(width); -return; +return *this; } // The sign bit is set. First, get some facts @@ -944,7 +944,7 @@ else pVal[wordsBefore-1] |= mask; clearUnusedBits(); -return; +return *this; } uint64_t mask = wordBits == 0 ? 0 : ~0ULL wordBits; @@ -961,11 +961,11 @@ if (wordsBefore != 1) delete [] pVal; pVal = newVal; - clearUnusedBits(); + return clearUnusedBits(); } // Zero extend to a new width. -void APInt::zext(uint32_t width) { +APInt APInt::zext(uint32_t width) { assert(width BitWidth Invalid APInt ZeroExtend request); assert(width = IntegerType::MAX_INT_BITS Too many bits); uint32_t wordsBefore = getNumWords(); @@ -982,6 +982,7 @@ delete [] pVal; pVal = newVal; } + return *this; } /// Arithmetic right-shift this APInt by shiftAmt. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [see] CVS: llvm-poolalloc/include/dsa/DSGraph.h
Changes in directory llvm-poolalloc/include/dsa: DSGraph.h updated: 1.110.2.4 - 1.110.2.4.2.1 --- Log message: Add recursive unknown --- Diffs of the changes: (+2 -0) DSGraph.h |2 ++ 1 files changed, 2 insertions(+) Index: llvm-poolalloc/include/dsa/DSGraph.h diff -u llvm-poolalloc/include/dsa/DSGraph.h:1.110.2.4 llvm-poolalloc/include/dsa/DSGraph.h:1.110.2.4.2.1 --- llvm-poolalloc/include/dsa/DSGraph.h:1.110.2.4 Wed Dec 13 15:58:18 2006 +++ llvm-poolalloc/include/dsa/DSGraph.hWed Feb 28 11:35:41 2007 @@ -506,6 +506,8 @@ }; void markIncompleteNodes(unsigned Flags); + void markUnknownNodes(); + // removeDeadNodes - Use a reachability analysis to eliminate subgraphs that // are unreachable. This often occurs because the data structure doesn't // escape into it's caller, and thus should be eliminated from the caller's ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Support/ConstantRange.h
Changes in directory llvm/include/llvm/Support: ConstantRange.h updated: 1.15 - 1.16 --- Log message: For PR1205: http://llvm.org/PR1205 : Convert ConstantRange class to use APInt internally as its value type for the constant range, instead of ConstantInt. --- Diffs of the changes: (+10 -4) ConstantRange.h | 14 ++ 1 files changed, 10 insertions(+), 4 deletions(-) Index: llvm/include/llvm/Support/ConstantRange.h diff -u llvm/include/llvm/Support/ConstantRange.h:1.15 llvm/include/llvm/Support/ConstantRange.h:1.16 --- llvm/include/llvm/Support/ConstantRange.h:1.15 Sat Feb 10 18:58:49 2007 +++ llvm/include/llvm/Support/ConstantRange.h Wed Feb 28 11:36:23 2007 @@ -30,6 +30,7 @@ #ifndef LLVM_SUPPORT_CONSTANT_RANGE_H #define LLVM_SUPPORT_CONSTANT_RANGE_H +#include llvm/ADT/APInt.h #include llvm/Support/DataTypes.h #include llvm/Support/Streams.h #include iosfwd @@ -40,7 +41,9 @@ class Type; class ConstantRange { - ConstantInt *Lower, *Upper; + APInt Lower, Upper; + static ConstantRange intersect1Wrapped(const ConstantRange LHS, + const ConstantRange RHS, bool sign); public: /// Initialize a full (the default) or empty set for the specified type. /// @@ -56,6 +59,9 @@ /// ConstantRange(Constant *Lower, Constant *Upper); + /// @brief Initialize a range of values explicitly. + ConstantRange(const APInt Lower, const APInt Upper); + /// Initialize a set of values that all satisfy the predicate with C. The /// predicate should be either an ICmpInst::Predicate or FCmpInst::Predicate /// value. @@ -64,11 +70,11 @@ /// getLower - Return the lower value for this range... /// - ConstantInt *getLower() const { return Lower; } + ConstantInt *getLower() const; /// getUpper - Return the upper value for this range... /// - ConstantInt *getUpper() const { return Upper; } + ConstantInt *getUpper() const; /// getType - Return the LLVM data type of this range. /// @@ -105,7 +111,7 @@ /// getSetSize - Return the number of elements in this set. /// - uint64_t getSetSize() const; + APInt getSetSize() const; /// operator== - Return true if this range is equal to another range. /// ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Analysis/ConstantRange.cpp
Changes in directory llvm/lib/Analysis: ConstantRange.cpp updated: 1.34 - 1.35 --- Log message: For PR1205: http://llvm.org/PR1205 : Convert ConstantRange class to use APInt internally as its value type for the constant range, instead of ConstantInt. --- Diffs of the changes: (+127 -138) ConstantRange.cpp | 265 +- 1 files changed, 127 insertions(+), 138 deletions(-) Index: llvm/lib/Analysis/ConstantRange.cpp diff -u llvm/lib/Analysis/ConstantRange.cpp:1.34 llvm/lib/Analysis/ConstantRange.cpp:1.35 --- llvm/lib/Analysis/ConstantRange.cpp:1.34Sat Feb 10 18:58:49 2007 +++ llvm/lib/Analysis/ConstantRange.cpp Wed Feb 28 11:36:23 2007 @@ -31,228 +31,212 @@ #include ostream using namespace llvm; -static ConstantInt *getMaxValue(const Type *Ty, bool isSigned = false) { - if (Ty-isInteger()) { -if (isSigned) { - // Calculate 011... - unsigned TypeBits = Ty-getPrimitiveSizeInBits(); - int64_t Val = INT64_MAX; // All ones - Val = 64-TypeBits; // Shift out unwanted 1 bits... - return ConstantInt::get(Ty, Val); -} -return ConstantInt::getAllOnesValue(Ty); - } - return 0; -} - -// Static constructor to create the minimum constant for an integral type... -static ConstantInt *getMinValue(const Type *Ty, bool isSigned = false) { - if (Ty-isInteger()) { -if (isSigned) { - // Calculate 11 - unsigned TypeBits = Ty-getPrimitiveSizeInBits(); - int64_t Val = -1;// All ones - Val = TypeBits-1; // Shift over to the right spot - return ConstantInt::get(Ty, Val); -} -return ConstantInt::get(Ty, 0); - } - return 0; -} -static ConstantInt *Next(ConstantInt *CI) { - Constant *Result = ConstantExpr::getAdd(CI, - ConstantInt::get(CI-getType(), 1)); - return castConstantInt(Result); -} - -static bool LT(ConstantInt *A, ConstantInt *B, bool isSigned) { - Constant *C = ConstantExpr::getICmp( -(isSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT), A, B); - assert(isaConstantInt(C) Constant folding of integrals not impl??); - return castConstantInt(C)-getZExtValue(); -} - -static bool LTE(ConstantInt *A, ConstantInt *B, bool isSigned) { - Constant *C = ConstantExpr::getICmp( -(isSigned ? ICmpInst::ICMP_SLE : ICmpInst::ICMP_ULE), A, B); - assert(isaConstantInt(C) Constant folding of integrals not impl??); - return castConstantInt(C)-getZExtValue(); -} - -static bool GT(ConstantInt *A, ConstantInt *B, bool isSigned) { - return LT(B, A, isSigned); } - -static ConstantInt *Min(ConstantInt *A, ConstantInt *B, - bool isSigned) { - return LT(A, B, isSigned) ? A : B; -} -static ConstantInt *Max(ConstantInt *A, ConstantInt *B, - bool isSigned) { - return GT(A, B, isSigned) ? A : B; -} - /// Initialize a full (the default) or empty set for the specified type. /// -ConstantRange::ConstantRange(const Type *Ty, bool Full) { - assert(Ty-isInteger() - Cannot make constant range of non-integral type!); +ConstantRange::ConstantRange(const Type *Ty, bool Full) : + Lower(castIntegerType(Ty)-getBitWidth(), 0), + Upper(castIntegerType(Ty)-getBitWidth(), 0) { + uint32_t BitWidth = castIntegerType(Ty)-getBitWidth(); if (Full) -Lower = Upper = getMaxValue(Ty); +Lower = Upper = APInt::getMaxValue(BitWidth); else -Lower = Upper = getMinValue(Ty); +Lower = Upper = APInt::getMinValue(BitWidth); } /// Initialize a range to hold the single specified value. /// ConstantRange::ConstantRange(Constant *V) - : Lower(castConstantInt(V)), Upper(Next(castConstantInt(V))) { } + : Lower(castConstantInt(V)-getValue()), +Upper(castConstantInt(V)-getValue() + 1) { } /// Initialize a range of values explicitly... this will assert out if /// Lower==Upper and Lower != Min or Max for its type (or if the two constants /// have different types) /// ConstantRange::ConstantRange(Constant *L, Constant *U) - : Lower(castConstantInt(L)), Upper(castConstantInt(U)) { - assert(Lower-getType() == Upper-getType() - Incompatible types for ConstantRange!); + : Lower(castConstantInt(L)-getValue()), +Upper(castConstantInt(U)-getValue()) { + assert(L-getType() == U-getType() Invalid ConstantRange types!); + assert(L-getType()-isInteger() Invalid ConstantRange types!); // Make sure that if L U are equal that they are either Min or Max... - assert((L != U || (L == getMaxValue(L-getType()) || - L == getMinValue(L-getType( + + uint32_t BitWidth = castIntegerType(L-getType())-getBitWidth(); + const IntegerType *Ty = castIntegerType(L-getType()); + assert((L != U || (L == ConstantInt::get(Ty, APInt::getMaxValue(BitWidth)) + || L == ConstantInt::get(Ty, APInt::getMinValue(BitWidth Lower == Upper, but
[llvm-commits] CVS: llvm/test/CodeGen/X86/fast-cc-callee-pops.ll
Changes in directory llvm/test/CodeGen/X86: fast-cc-callee-pops.ll updated: 1.4 - 1.5 --- Log message: fastcc - fastcall --- Diffs of the changes: (+1 -1) fast-cc-callee-pops.ll |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/test/CodeGen/X86/fast-cc-callee-pops.ll diff -u llvm/test/CodeGen/X86/fast-cc-callee-pops.ll:1.4 llvm/test/CodeGen/X86/fast-cc-callee-pops.ll:1.5 --- llvm/test/CodeGen/X86/fast-cc-callee-pops.ll:1.4Fri Dec 1 22:23:08 2006 +++ llvm/test/CodeGen/X86/fast-cc-callee-pops.llWed Feb 28 11:42:50 2007 @@ -2,6 +2,6 @@ ; Check that a fastcc function pops its stack variables before returning. -fastcc void %func(long %X, long %Y, float %G, double %Z) { +cc65 void %func(long %X, long %Y, float %G, double %Z) { ret void } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] llvm-gcc: support arrays with non-zero lower bound
Ada arrays need not be indexed from zero: the indexing can start from any number, positive or negative. While some parts of llvm-gcc had support for non-zero lower bounds, not everywhere did. This patch adds consistent support everywhere. Also, it considers an array to have dynamic size if the length is not constant, rather than when the maximum index is not constant, which is the current test. Thus an array with index range n..n+4 is considered to have length 5, a constant [*]. This notion of array size is also used consistently everywhere. The impact on non-Ada code should be insignificant. The potential additional costs come from: (1) converting array bounds to sizetype; (2) having gcc subtract off the lower bound; and (3) having gcc add one. In C it seems that array bounds are already of type sizetype (I added an assert and it didn't trigger when building the C compiler); fold_convert instantly exits in this case, so the cost of (1) is infinitesimal. In C the lower bound is always 0; size_binop does a quick return in this case, so the cost of (2) is also infinitesimal. For C, (3) involves adding one to a constant, which does not involve any heavy operations like memory allocation, just a two word integer plus operation. So this can also be considered to be zero. The attachment array_test.diff adds an LLVM testcase to test/AdaFrontend. This is currently useless since the Ada compiler does not build. There is also no LLVM build support for test/AdaFrontend yet. Best wishes, Duncan. [*] this optimization is currently of no benefit to the Ada compiler: it generates n..max(n-1,n+4) as the array bounds. Fold fails to simplify max(n-1,n+4) to n+4 for obscure reasons which I am looking into (a fold guru tells me it is supposed to work). Index: gcc.llvm.master/gcc/llvm-convert.cpp === --- gcc.llvm.master.orig/gcc/llvm-convert.cpp 2007-02-28 12:01:19.0 +0100 +++ gcc.llvm.master/gcc/llvm-convert.cpp 2007-02-28 18:34:07.0 +0100 @@ -1329,18 +1329,14 @@ DECL_USER_ALIGN(decl) = 0; Alignment = DECL_ALIGN(decl)/8; } else { +tree length; + // Dynamic-size object: must push space on the stack. -if (TREE_CODE(type) == ARRAY_TYPE TYPE_DOMAIN(type)) { +if (TREE_CODE(type) == ARRAY_TYPE (length = arrayLength(type))) { Ty = ConvertType(TREE_TYPE(type)); // Get array element type. - // Compute the size of the number of elements of the array. - Size = Emit(TYPE_MAX_VALUE(TYPE_DOMAIN(type)), 0); - Size = CastToUIntType(Size, Type::Int32Ty); - - // Annoyingly, TYPE_MAX_VALUE returns the maximum valid index, NOT the - // number of elements in the array. Thus, we must add one to the returned - // value. This addition should be optimized out later. - Size = BinaryOperator::createAdd(Size, ConstantInt::get(Type::Int32Ty, 1), - tmp, CurBB); + // Compute the number of elements in the array. + Size = Emit(length, 0); + Size = CastToUIntType(Size, Size-getType()); } else { // Compute the variable's size in bytes. Size = CastToUIntType(Emit(DECL_SIZE_UNIT(decl), 0), Type::Int32Ty); @@ -4246,9 +4242,8 @@ // Check for variable sized array reference. if (TREE_CODE(TREE_TYPE(Array)) == ARRAY_TYPE) { -tree Domain = TYPE_DOMAIN(TREE_TYPE(Array)); -if (Domain TYPE_MAX_VALUE(Domain) -TREE_CODE(TYPE_MAX_VALUE(Domain)) != INTEGER_CST) { +tree length = arrayLength(TREE_TYPE(Array)); +if (length !host_integerp(length, 1)) { // Make sure that ArrayAddr is of type ElementTy*, then do a 2-index gep. tree ElTy = TREE_TYPE(TREE_TYPE(Array)); // This cast only deals with pointers so BitCast is appropriate @@ -4668,7 +4663,7 @@ // If this is a variable sized array type, set the length to Len. if (ConstantSize == 0) { tree Domain = TYPE_DOMAIN(TREE_TYPE(exp)); - if (Domain == 0 || TYPE_MAX_VALUE(Domain) == 0) { + if (!Domain || !TYPE_MAX_VALUE(Domain)) { ConstantSize = Len; StrTy = ArrayType::get(ElTy, Len); } @@ -4767,21 +4762,23 @@ // type indirectly. assert(TREE_CODE(TREE_TYPE(exp)) != VECTOR_TYPE VECTOR_TYPE's haven't been tested!); - - // If we have constant lower bound for the range of the type, get it. */ + + // If we have a lower bound for the range of the type, get it. */ tree Domain = TYPE_DOMAIN(TREE_TYPE(exp)); - unsigned MinElement = 0; - if (Domain TYPE_MIN_VALUE(Domain) - host_integerp(TYPE_MIN_VALUE(Domain), 0)) -MinElement = tree_low_cst(TYPE_MIN_VALUE(Domain), 0); - + tree min_element = size_zero_node; + if (Domain TYPE_MIN_VALUE(Domain)) +min_element = fold_convert(sizetype, TYPE_MIN_VALUE(Domain)); + std::vectorConstant* ResultElts; Constant *SomeVal = 0; - if (Domain TYPE_MAX_VALUE(Domain) -
[llvm-commits] llvm-gcc: support for NON_LVALUE_EXPR
According to the docs: NON_LVALUE_EXPR These nodes indicate that their one and only operand is not an lvalue. A back end can treat these identically to the single operand. And that is what this patch does. Ciao, Duncan. Index: gcc.llvm.master/gcc/llvm-convert.cpp === --- gcc.llvm.master.orig/gcc/llvm-convert.cpp 2007-02-28 19:15:47.0 +0100 +++ gcc.llvm.master/gcc/llvm-convert.cpp 2007-02-28 19:15:49.0 +0100 @@ -680,6 +680,9 @@ case CALL_EXPR: Result = EmitCALL_EXPR(exp, DestLoc); break; case MODIFY_EXPR:Result = EmitMODIFY_EXPR(exp, DestLoc); break; case ASM_EXPR: Result = EmitASM_EXPR(exp); break; + case NON_LVALUE_EXPR: +Result = Emit(TREE_OPERAND(exp, 0), DestLoc); +break; // Unary Operators case NOP_EXPR: Result = EmitNOP_EXPR(exp, DestLoc); break; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/test/CodeGen/X86/fast-cc-callee-pops.ll fast-cc-merge-stack-adj.ll
Changes in directory llvm/test/CodeGen/X86: fast-cc-callee-pops.ll updated: 1.5 - 1.6 fast-cc-merge-stack-adj.ll updated: 1.5 - 1.6 --- Log message: fastcc - fastcall --- Diffs of the changes: (+4 -4) fast-cc-callee-pops.ll |2 +- fast-cc-merge-stack-adj.ll |6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/test/CodeGen/X86/fast-cc-callee-pops.ll diff -u llvm/test/CodeGen/X86/fast-cc-callee-pops.ll:1.5 llvm/test/CodeGen/X86/fast-cc-callee-pops.ll:1.6 --- llvm/test/CodeGen/X86/fast-cc-callee-pops.ll:1.5Wed Feb 28 11:42:50 2007 +++ llvm/test/CodeGen/X86/fast-cc-callee-pops.llWed Feb 28 12:21:50 2007 @@ -2,6 +2,6 @@ ; Check that a fastcc function pops its stack variables before returning. -cc65 void %func(long %X, long %Y, float %G, double %Z) { +x86_fastcallcc void %func(long %X, long %Y, float %G, double %Z) { ret void } Index: llvm/test/CodeGen/X86/fast-cc-merge-stack-adj.ll diff -u llvm/test/CodeGen/X86/fast-cc-merge-stack-adj.ll:1.5 llvm/test/CodeGen/X86/fast-cc-merge-stack-adj.ll:1.6 --- llvm/test/CodeGen/X86/fast-cc-merge-stack-adj.ll:1.5Fri Dec 1 22:23:08 2006 +++ llvm/test/CodeGen/X86/fast-cc-merge-stack-adj.llWed Feb 28 12:21:50 2007 @@ -2,10 +2,10 @@ target triple = i686-pc-linux-gnu -declare fastcc void %func(int *%X, long %Y) +declare x86_fastcallcc void %func(int *%X, long %Y) -fastcc void %caller(int, long) { +x86_fastcallcc void %caller(int, long) { %X = alloca int - call fastcc void %func(int* %X, long 0) ;; not a tail call + call x86_fastcallcc void %func(int* %X, long 0) ;; not a tail call ret void } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] ConstantRange
On Wed, 2007-02-28 at 10:11 -0800, Chris Lattner wrote: On Feb 28, 2007, at 8:29 AM, Reid Spencer wrote: Chris, I have converted ConstantRange to use APInt internally. This simplified it and got rid of some of the helper functions inside ConstantRange (because they have equivalents in APInt). Now I'm thinking that ConstantRange should completely avoid the use of ConstantInt in its API and replace all such uses with APInt. This would mean that the class could be implemented in lib/Support instead of lib/Analysis because it would no longer depend on lib/VMCore. Is this a desirable change? Very desirable! Or, do you want the interface to still work with ConstantInt? No need, the clients of ConstantRange can do the xlation. Okay, I will make it so in increments. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/X86/X86CallingConv.td
Changes in directory llvm/lib/Target/X86: X86CallingConv.td updated: 1.9 - 1.10 --- Log message: bugfix: fastcall does not require the first two params to be marked 'inreg', they always get registers. --- Diffs of the changes: (+1 -1) X86CallingConv.td |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/X86/X86CallingConv.td diff -u llvm/lib/Target/X86/X86CallingConv.td:1.9 llvm/lib/Target/X86/X86CallingConv.td:1.10 --- llvm/lib/Target/X86/X86CallingConv.td:1.9 Wed Feb 28 00:20:01 2007 +++ llvm/lib/Target/X86/X86CallingConv.td Wed Feb 28 12:35:11 2007 @@ -148,7 +148,7 @@ CCIfType[i8, i16], CCPromoteToTypei32, // The first 2 integer arguments are passed in ECX/EDX - CCIfInRegCCIfType[i32], CCAssignToReg[ECX, EDX], + CCIfType[i32], CCAssignToReg[ECX, EDX], // Otherwise, same as everything else. CCDelegateToCC_X86_32_Common ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/test/CodeGen/X86/fast-cc-pass-in-regs.ll
Changes in directory llvm/test/CodeGen/X86: fast-cc-pass-in-regs.ll updated: 1.6 - 1.7 --- Log message: fastcc - fastcall --- Diffs of the changes: (+8 -10) fast-cc-pass-in-regs.ll | 18 -- 1 files changed, 8 insertions(+), 10 deletions(-) Index: llvm/test/CodeGen/X86/fast-cc-pass-in-regs.ll diff -u llvm/test/CodeGen/X86/fast-cc-pass-in-regs.ll:1.6 llvm/test/CodeGen/X86/fast-cc-pass-in-regs.ll:1.7 --- llvm/test/CodeGen/X86/fast-cc-pass-in-regs.ll:1.6 Fri Dec 1 22:23:08 2006 +++ llvm/test/CodeGen/X86/fast-cc-pass-in-regs.ll Wed Feb 28 12:35:36 2007 @@ -1,16 +1,14 @@ -; RUN: llvm-upgrade %s | llvm-as | llc -march=x86 -x86-asm-syntax=intel -enable-x86-fastcc | grep 'mov EDX, 1' +; RUN: llvm-as %s | llc -march=x86 -x86-asm-syntax=intel | grep 'mov EDX, 1' ; check that fastcc is passing stuff in regs. -; Argument reg passing is disabled due to regalloc issues. FIXME! -; XFAIL: * +declare x86_fastcallcc i64 @callee(i64) -declare fastcc long %callee(long) - -long %caller() { - %X = call fastcc long %callee(long 4294967299) ;; (1ULL 32) + 3 - ret long %X +define i64 @caller() { +%X = callx86_fastcallcc i64 @callee( i64 4294967299 ) ; i64 [#uses=1] +ret i64 %X } -fastcc long %caller2(long %X) { - ret long %X +define x86_fastcallcc i64 @caller2(i64 %X) { +ret i64 %X } + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Intrinsics.td
Changes in directory llvm/include/llvm: Intrinsics.td updated: 1.47 - 1.48 --- Log message: Provide a more meaningful name. --- Diffs of the changes: (+1 -1) Intrinsics.td |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/include/llvm/Intrinsics.td diff -u llvm/include/llvm/Intrinsics.td:1.47 llvm/include/llvm/Intrinsics.td:1.48 --- llvm/include/llvm/Intrinsics.td:1.47Wed Feb 21 16:35:57 2007 +++ llvm/include/llvm/Intrinsics.td Wed Feb 28 12:35:44 2007 @@ -232,7 +232,7 @@ //===-- Exception Handling Intrinsics--===// // def int_eh_exception : Intrinsic[llvm_ptr_ty]; -def int_eh_handlers : Intrinsic[llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, +def int_eh_selector : Intrinsic[llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_vararg_ty]; def int_eh_typeid_for : Intrinsic[llvm_i32_ty, llvm_ptr_ty]; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.377 - 1.378 --- Log message: MERGE_VALUES unnecessary. --- Diffs of the changes: (+4 -12) SelectionDAGISel.cpp | 16 1 files changed, 4 insertions(+), 12 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.377 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.378 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.377Sun Feb 25 20:56:58 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed Feb 28 12:37:04 2007 @@ -2105,16 +2105,12 @@ setValue(I, Op); DAG.setRoot(Op.getValue(1)); } else { - SDOperand Op = DAG.getNode(ISD::MERGE_VALUES, TLI.getPointerTy(), - DAG.getConstant(0, TLI.getPointerTy()), - DAG.getRoot()); - setValue(I, Op); - DAG.setRoot(Op.getValue(1)); + setValue(I, DAG.getConstant(0, TLI.getPointerTy())); } return 0; } - case Intrinsic::eh_handlers: { + case Intrinsic::eh_selector: { MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); if (MMI) { @@ -2147,7 +2143,7 @@ if (Reg) CurMBB-addLiveIn(Reg); // Insert the EHSELECTION instruction. - SDVTList VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other); + SDVTList VTs = DAG.getVTList(MVT::i32, MVT::Other); SDOperand Ops[2]; Ops[0] = getValue(I.getOperand(1)); Ops[1] = getRoot(); @@ -2155,11 +2151,7 @@ setValue(I, Op); DAG.setRoot(Op.getValue(1)); } else { - SDOperand Op = DAG.getNode(ISD::MERGE_VALUES, TLI.getPointerTy(), - DAG.getConstant(0, TLI.getPointerTy()), - getValue(I.getOperand(1))); - setValue(I, Op); - DAG.setRoot(Op.getValue(1)); + setValue(I, DAG.getConstant(0, MVT::i32)); } return 0; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/IntrinsicLowering.cpp
Changes in directory llvm/lib/CodeGen: IntrinsicLowering.cpp updated: 1.70 - 1.71 --- Log message: Provide a more meaningful name. --- Diffs of the changes: (+1 -1) IntrinsicLowering.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/CodeGen/IntrinsicLowering.cpp diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.70 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.71 --- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.70 Thu Feb 22 12:51:19 2007 +++ llvm/lib/CodeGen/IntrinsicLowering.cpp Wed Feb 28 12:37:50 2007 @@ -357,7 +357,7 @@ case Intrinsic::dbg_func_start: case Intrinsic::dbg_declare: case Intrinsic::eh_exception: - case Intrinsic::eh_handlers: + case Intrinsic::eh_selector: break;// Simply strip out debugging and eh intrinsics case Intrinsic::memcpy_i32: ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/test/CodeGen/X86/2005-12-03-IndirectTailCall.ll 2006-10-02-BoolRetCrash.ll fast-cc-callee-pops.ll fast-cc-merge-stack-adj.ll fast-cc-tail-call.ll
Changes in directory llvm/test/CodeGen/X86: 2005-12-03-IndirectTailCall.ll updated: 1.4 - 1.5 2006-10-02-BoolRetCrash.ll updated: 1.2 - 1.3 fast-cc-callee-pops.ll updated: 1.6 - 1.7 fast-cc-merge-stack-adj.ll updated: 1.6 - 1.7 fast-cc-tail-call.ll updated: 1.4 - 1.5 --- Log message: Eliminate enable-x86-fastcc --- Diffs of the changes: (+5 -6) 2005-12-03-IndirectTailCall.ll |2 +- 2006-10-02-BoolRetCrash.ll |3 +-- fast-cc-callee-pops.ll |2 +- fast-cc-merge-stack-adj.ll |2 +- fast-cc-tail-call.ll |2 +- 5 files changed, 5 insertions(+), 6 deletions(-) Index: llvm/test/CodeGen/X86/2005-12-03-IndirectTailCall.ll diff -u llvm/test/CodeGen/X86/2005-12-03-IndirectTailCall.ll:1.4 llvm/test/CodeGen/X86/2005-12-03-IndirectTailCall.ll:1.5 --- llvm/test/CodeGen/X86/2005-12-03-IndirectTailCall.ll:1.4Fri Dec 1 22:23:08 2006 +++ llvm/test/CodeGen/X86/2005-12-03-IndirectTailCall.llWed Feb 28 12:38:58 2007 @@ -1,5 +1,5 @@ ; XFAIL: * -; RUN: llvm-upgrade %s | llvm-as | llc -march=x86 -enable-x86-fastcc | grep 'jmp \*ecx' +; RUN: llvm-upgrade %s | llvm-as | llc -march=x86 | grep 'jmp \*ecx' declare int %putchar(int) int %main(){ Index: llvm/test/CodeGen/X86/2006-10-02-BoolRetCrash.ll diff -u llvm/test/CodeGen/X86/2006-10-02-BoolRetCrash.ll:1.2 llvm/test/CodeGen/X86/2006-10-02-BoolRetCrash.ll:1.3 --- llvm/test/CodeGen/X86/2006-10-02-BoolRetCrash.ll:1.2Fri Dec 1 22:23:08 2006 +++ llvm/test/CodeGen/X86/2006-10-02-BoolRetCrash.llWed Feb 28 12:38:58 2007 @@ -1,5 +1,4 @@ -; RUN: llvm-upgrade %s | llvm-as | llc -; RUN: llvm-upgrade %s | llvm-as | llc -enable-x86-fastcc +; RUN: llvm-upgrade %s | llvm-as | llc ; PR933 fastcc bool %test() { Index: llvm/test/CodeGen/X86/fast-cc-callee-pops.ll diff -u llvm/test/CodeGen/X86/fast-cc-callee-pops.ll:1.6 llvm/test/CodeGen/X86/fast-cc-callee-pops.ll:1.7 --- llvm/test/CodeGen/X86/fast-cc-callee-pops.ll:1.6Wed Feb 28 12:21:50 2007 +++ llvm/test/CodeGen/X86/fast-cc-callee-pops.llWed Feb 28 12:38:58 2007 @@ -1,4 +1,4 @@ -; RUN: llvm-upgrade %s | llvm-as | llc -march=x86 -x86-asm-syntax=intel -enable-x86-fastcc -mcpu=yonah | grep 'ret 28' +; RUN: llvm-upgrade %s | llvm-as | llc -march=x86 -x86-asm-syntax=intel -mcpu=yonah | grep 'ret 28' ; Check that a fastcc function pops its stack variables before returning. Index: llvm/test/CodeGen/X86/fast-cc-merge-stack-adj.ll diff -u llvm/test/CodeGen/X86/fast-cc-merge-stack-adj.ll:1.6 llvm/test/CodeGen/X86/fast-cc-merge-stack-adj.ll:1.7 --- llvm/test/CodeGen/X86/fast-cc-merge-stack-adj.ll:1.6Wed Feb 28 12:21:50 2007 +++ llvm/test/CodeGen/X86/fast-cc-merge-stack-adj.llWed Feb 28 12:38:58 2007 @@ -1,4 +1,4 @@ -; RUN: llvm-upgrade %s | llvm-as | llc -march=x86 -x86-asm-syntax=intel -enable-x86-fastcc | grep 'add ESP, 8' +; RUN: llvm-upgrade %s | llvm-as | llc -march=x86 -x86-asm-syntax=intel | grep 'add ESP, 8' target triple = i686-pc-linux-gnu Index: llvm/test/CodeGen/X86/fast-cc-tail-call.ll diff -u llvm/test/CodeGen/X86/fast-cc-tail-call.ll:1.4 llvm/test/CodeGen/X86/fast-cc-tail-call.ll:1.5 --- llvm/test/CodeGen/X86/fast-cc-tail-call.ll:1.4 Fri Dec 1 22:23:08 2006 +++ llvm/test/CodeGen/X86/fast-cc-tail-call.ll Wed Feb 28 12:38:58 2007 @@ -1,5 +1,5 @@ ; XFAIL: * -; RUN: llvm-upgrade %s | llvm-as | llc -march=x86 -x86-asm-syntax=intel -enable-x86-fastcc | not grep call +; RUN: llvm-upgrade %s | llvm-as | llc -march=x86 -x86-asm-syntax=intel | not grep call fastcc int %bar(int %X, int(double, int) *%FP) { %Y = tail call fastcc int %FP(double 0.0, int %X) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp
Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.355 - 1.356 --- Log message: remove dead option --- Diffs of the changes: (+0 -4) X86ISelLowering.cpp |4 1 files changed, 4 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.355 llvm/lib/Target/X86/X86ISelLowering.cpp:1.356 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.355 Wed Feb 28 01:09:55 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Wed Feb 28 12:39:53 2007 @@ -32,13 +32,9 @@ #include llvm/CodeGen/SSARegMap.h #include llvm/Support/MathExtras.h #include llvm/Target/TargetOptions.h -#include llvm/Support/CommandLine.h #include llvm/ADT/StringExtras.h using namespace llvm; -// FIXME: temporary. -static cl::optbool EnableFastCC(enable-x86-fastcc, cl::Hidden, - cl::desc(Enable fastcc on X86)); X86TargetLowering::X86TargetLowering(TargetMachine TM) : TargetLowering(TM) { Subtarget = TM.getSubtargetX86Subtarget(); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp README.txt
Changes in directory llvm/lib/Target/ARM: ARMConstantIslandPass.cpp updated: 1.30 - 1.31 README.txt updated: 1.14 - 1.15 --- Log message: Add intelligence about where to break large blocks. --- Diffs of the changes: (+80 -35) ARMConstantIslandPass.cpp | 96 ++ README.txt| 19 +++-- 2 files changed, 80 insertions(+), 35 deletions(-) Index: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp diff -u llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.30 llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.31 --- llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.30 Sun Feb 25 12:31:31 2007 +++ llvm/lib/Target/ARM/ARMConstantIslandPass.cpp Wed Feb 28 12:41:22 2007 @@ -140,7 +140,7 @@ void AdjustBBOffsetsAfter(MachineBasicBlock *BB, int delta); bool DecrementOldEntry(unsigned CPI, MachineInstr* CPEMI, unsigned Size); int LookForExistingCPEntry(CPUser U, unsigned UserOffset); -bool HandleConstantPoolUser(MachineFunction Fn, CPUser U); +bool HandleConstantPoolUser(MachineFunction Fn, unsigned CPUserIndex); bool CPEIsInRange(MachineInstr *MI, unsigned UserOffset, MachineInstr *CPEMI, unsigned Disp, bool DoDump); @@ -197,7 +197,7 @@ while (true) { bool Change = false; for (unsigned i = 0, e = CPUsers.size(); i != e; ++i) - Change |= HandleConstantPoolUser(Fn, CPUsers[i]); + Change |= HandleConstantPoolUser(Fn, i); for (unsigned i = 0, e = ImmBranches.size(); i != e; ++i) Change |= FixUpImmediateBr(Fn, ImmBranches[i]); if (!Change) @@ -722,11 +722,19 @@ return 0; } +/// getUnconditionalBrDisp - Returns the maximum displacement that can fit in +/// the specific unconditional branch instruction. +static inline unsigned getUnconditionalBrDisp(int Opc) { + return (Opc == ARM::tB) ? ((110)-1)*2 : ((123)-1)*4; +} + /// HandleConstantPoolUser - Analyze the specified user, checking to see if it /// is out-of-range. If so, pick it up the constant pool value and move it some /// place in-range. Return true if we changed any addresses (thus must run /// another pass of branch lengthening), false otherwise. -bool ARMConstantIslands::HandleConstantPoolUser(MachineFunction Fn, CPUser U){ +bool ARMConstantIslands::HandleConstantPoolUser(MachineFunction Fn, +unsigned CPUserIndex){ + CPUser U = CPUsers[CPUserIndex]; MachineInstr *UserMI = U.MI; MachineInstr *CPEMI = U.CPEMI; unsigned CPI = CPEMI-getOperand(1).getConstantPoolIndex(); @@ -750,6 +758,7 @@ // away that will work. Forward references only for now (although later // we might find some that are backwards). bool WaterFound = false; + bool PadNewWater = true; if (!WaterList.empty()) { for (std::vectorMachineBasicBlock*::iterator IP = prior(WaterList.end()), B = WaterList.begin();; --IP) { @@ -759,6 +768,17 @@ DOUT found water in range\n; // CPE goes before following block (NewMBB). NewMBB = next(MachineFunction::iterator(WaterBB)); +// If WaterBB is an island, don't pad the new island. +// If WaterBB is empty, go backwards until we find something that +// isn't. WaterBB may become empty if it's an island whose +// contents were moved farther back. +if (isThumb) { + MachineBasicBlock* BB = WaterBB; + while (BB-empty()) +BB = BB-Prev; + if (BB-begin()-getOpcode() == ARM::CONSTPOOL_ENTRY) +PadNewWater = false; +} // Remove the original WaterList entry; we want subsequent // insertions in this vicinity to go after the one we're // about to insert. This considerably reduces the number @@ -776,22 +796,32 @@ DOUT No water found\n; MachineBasicBlock *UserMBB = UserMI-getParent(); -unsigned TrialOffset = BBOffsets[UserMBB-getNumber()] + - BBSizes[UserMBB-getNumber()] + - isThumb ? 2 : 4; /* for branch to be added */ +unsigned OffsetOfNextBlock = BBOffsets[UserMBB-getNumber()] + + BBSizes[UserMBB-getNumber()]; +assert(OffsetOfNextBlock = BBOffsets[UserMBB-getNumber()+1]); // If the use is at the end of the block, or the end of the block -// is within range, make new water there. (If the block ends in +// is within range, make new water there. (The +2 or 4 below is +// for the unconditional branch we will be adding. If the block ends in // an unconditional branch already, it is water, and is known to -// be out of range; so it's OK to assume above we'll be adding a Br.) +// be out of range, so we'll always be adding one.) if (UserMBB-back() == UserMI || -OffsetIsInRange(UserOffset, TrialOffset, U.MaxDisp, !isThumb)) { +OffsetIsInRange(UserOffset, OffsetOfNextBlock + (isThumb ? 2 : 4), +
[llvm-commits] New pass for review
Hello, Everyone. Please find new optimization pass for LLVM attached. Actually, it implements llvm-to-llvm transformation of switches, lowering their complexity (in terms of comparisons/jumps needed). It does techniques listed in PR926: 1. MRST for sparse switches (they are converted in the series of switches suitable for jump table emission) 2. Shift/And technique for small switches with few destinations. Tested with: 1. llvm-test 2. 1) llvm-gcc bootstraped 2) Mozilla build with bootstrapped llvm-gcc -- With best regards, Anton Korobeynikov. Faculty of Mathematics Mechanics, Saint Petersburg State University. diff -r 87cd8438fce8 include/llvm/LinkAllPasses.h --- a/include/llvm/LinkAllPasses.h Mon Feb 26 18:56:07 2007 + +++ b/include/llvm/LinkAllPasses.h Sat Feb 24 23:31:48 2007 +0300 @@ -109,6 +109,7 @@ namespace { (void) llvm::createIndMemRemPass(); (void) llvm::createInstCountPass(); (void) llvm::createPredicateSimplifierPass(); + (void) llvm::createSwitchStrengthReducePass(); (void)new llvm::IntervalPartition(); (void)new llvm::ImmediateDominators(); diff -r 87cd8438fce8 include/llvm/Transforms/Scalar.h --- a/include/llvm/Transforms/Scalar.h Mon Feb 26 18:56:07 2007 + +++ b/include/llvm/Transforms/Scalar.h Sat Feb 24 23:39:49 2007 +0300 @@ -133,6 +133,13 @@ FunctionPass *createLoopUnswitchPass(); // LoopUnroll - This pass is a simple loop unrolling pass. // FunctionPass *createLoopUnrollPass(); + +//===--===// +// +// SwitchStrengthReduce - This pass performs a strength reduction on switch +// instructions, replacing them by code which has lower amount of jumps. +FunctionPass *createSwitchStrengthReducePass(); +extern const PassInfo *SwitchStrengthReduceID; //===--===// // diff -r 87cd8438fce8 lib/CodeGen/LLVMTargetMachine.cpp --- a/lib/CodeGen/LLVMTargetMachine.cpp Mon Feb 26 18:56:07 2007 + +++ b/lib/CodeGen/LLVMTargetMachine.cpp Sun Feb 25 16:28:35 2007 +0300 @@ -26,8 +26,11 @@ LLVMTargetMachine::addPassesToEmitFile(F bool Fast) { // Standard LLVM-Level Passes. - // Run loop strength reduction before anything else. - if (!Fast) PM.add(createLoopStrengthReducePass(getTargetLowering())); + // Run loop switch strength reduction before anything else. + if (!Fast) { +PM.add(createLoopStrengthReducePass(getTargetLowering())); +PM.add(createSwitchStrengthReducePass()); + } // FIXME: Implement efficient support for garbage collection intrinsics. PM.add(createLowerGCPass()); //===- SwitchStrengthReduce.cpp - Reduce switch strength --===// // // The LLVM Compiler Infrastructure // // This file was developed by Anton Korobeynikov and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. // //===--===// // // This pass performs a strength reduction on switch instructions, // replacing them by code, which has lower amount of jumps. // // This pass implements 2 techniques: // 1. Shift/And switch lowering for dense switches with few destinations // 2. MRST algorithm for sparse switches described in this paper: //Efficient Multiway Radix Search Trees //Ulfar Erlingsson, Mukkai Krishnamoorthy and T.V. Raman. //Information Processing Letters 60(1996), pp. 115-120. //http://www.cs.cornell.edu/home/ulfar/mrst.ps.gz //===--===// #include llvm/Transforms/Scalar.h #include llvm/Transforms/Utils/UnifyFunctionExitNodes.h #include llvm/Constants.h #include llvm/DerivedTypes.h #include llvm/Function.h #include llvm/Instructions.h #include llvm/Pass.h #include llvm/ADT/SmallSet.h #include llvm/Support/Debug.h #include llvm/Support/Compiler.h #include llvm/Target/TargetData.h #include algorithm #include list #include iostream using namespace llvm; #define MAX_CASE_BIT_TESTS 3 namespace { /// SwitchStrengthReduce Pass class VISIBILITY_HIDDEN SwitchStrengthReduce : public FunctionPass { public: const TargetData *TD; const Type *UIntPtrTy; virtual bool runOnFunction(Function F); virtual void getAnalysisUsage(AnalysisUsage AU) const { // This is a cluster of orthogonal Transforms AU.addPreservedUnifyFunctionExitNodes(); AU.addPreservedID(PromoteMemoryToRegisterID); AU.addPreservedID(LowerSelectID); AU.addPreservedID(LowerInvokePassID); AU.addPreservedID(LowerAllocationsID); AU.addRequiredTargetData(); } struct Case { Constant* Low; Constant* High; BasicBlock* BB; Case(Constant* _Low = NULL, Constant* _High = NULL, BasicBlock* _BB = NULL): Low(_Low), High(_High), BB(_BB) { } }; struct
[llvm-commits] CVS: llvm/lib/Analysis/ConstantRange.cpp ScalarEvolution.cpp
Changes in directory llvm/lib/Analysis: ConstantRange.cpp updated: 1.35 - 1.36 ScalarEvolution.cpp updated: 1.93 - 1.94 --- Log message: For PR1205: http://llvm.org/PR1205 : First round of ConstantRange changes. This makes all CR constructors use only APInt and not use ConstantInt. Clients are adjusted accordingly. --- Diffs of the changes: (+23 -49) ConstantRange.cpp | 61 +++- ScalarEvolution.cpp | 11 - 2 files changed, 23 insertions(+), 49 deletions(-) Index: llvm/lib/Analysis/ConstantRange.cpp diff -u llvm/lib/Analysis/ConstantRange.cpp:1.35 llvm/lib/Analysis/ConstantRange.cpp:1.36 --- llvm/lib/Analysis/ConstantRange.cpp:1.35Wed Feb 28 11:36:23 2007 +++ llvm/lib/Analysis/ConstantRange.cpp Wed Feb 28 12:57:32 2007 @@ -45,28 +45,7 @@ /// Initialize a range to hold the single specified value. /// -ConstantRange::ConstantRange(Constant *V) - : Lower(castConstantInt(V)-getValue()), -Upper(castConstantInt(V)-getValue() + 1) { } - -/// Initialize a range of values explicitly... this will assert out if -/// Lower==Upper and Lower != Min or Max for its type (or if the two constants -/// have different types) -/// -ConstantRange::ConstantRange(Constant *L, Constant *U) - : Lower(castConstantInt(L)-getValue()), -Upper(castConstantInt(U)-getValue()) { - assert(L-getType() == U-getType() Invalid ConstantRange types!); - assert(L-getType()-isInteger() Invalid ConstantRange types!); - - // Make sure that if L U are equal that they are either Min or Max... - - uint32_t BitWidth = castIntegerType(L-getType())-getBitWidth(); - const IntegerType *Ty = castIntegerType(L-getType()); - assert((L != U || (L == ConstantInt::get(Ty, APInt::getMaxValue(BitWidth)) - || L == ConstantInt::get(Ty, APInt::getMinValue(BitWidth - Lower == Upper, but they aren't min or max for type!); -} +ConstantRange::ConstantRange(const APInt V) : Lower(V), Upper(V + 1) { } ConstantRange::ConstantRange(const APInt L, const APInt U) : Lower(L), Upper(U) { @@ -80,45 +59,43 @@ /// Initialize a set of values that all satisfy the condition with C. /// -ConstantRange::ConstantRange(unsigned short ICmpOpcode, ConstantInt *C) - : Lower(castIntegerType(C-getType())-getBitWidth(), 0), -Upper(castIntegerType(C-getType())-getBitWidth(), 0) { - const APInt Val = C-getValue(); - uint32_t BitWidth = castIntegerType(C-getType())-getBitWidth(); +ConstantRange::ConstantRange(unsigned short ICmpOpcode, const APInt C) + : Lower(C.getBitWidth(), 0), Upper(C.getBitWidth(), 0) { + uint32_t BitWidth = C.getBitWidth(); switch (ICmpOpcode) { default: assert(0 Invalid ICmp opcode to ConstantRange ctor!); - case ICmpInst::ICMP_EQ: Lower = Val; Upper = Val + 1; return; - case ICmpInst::ICMP_NE: Upper = Val; Lower = Val + 1; return; + case ICmpInst::ICMP_EQ: Lower = C; Upper = C + 1; return; + case ICmpInst::ICMP_NE: Upper = C; Lower = C + 1; return; case ICmpInst::ICMP_ULT: Lower = APInt::getMinValue(BitWidth); -Upper = Val; +Upper = C; return; case ICmpInst::ICMP_SLT: Lower = APInt::getSignedMinValue(BitWidth); -Upper = Val; +Upper = C; return; case ICmpInst::ICMP_UGT: -Lower = Val + 1; +Lower = C + 1; Upper = APInt::getMinValue(BitWidth);// Min = Next(Max) return; case ICmpInst::ICMP_SGT: -Lower = Val + 1; +Lower = C + 1; Upper = APInt::getSignedMinValue(BitWidth); // Min = Next(Max) return; case ICmpInst::ICMP_ULE: Lower = APInt::getMinValue(BitWidth); -Upper = Val + 1; +Upper = C + 1; return; case ICmpInst::ICMP_SLE: Lower = APInt::getSignedMinValue(BitWidth); -Upper = Val + 1; +Upper = C + 1; return; case ICmpInst::ICMP_UGE: -Lower = Val; +Lower = C; Upper = APInt::getMinValue(BitWidth);// Min = Next(Max) return; case ICmpInst::ICMP_SGE: -Lower = Val; +Lower = C; Upper = APInt::getSignedMinValue(BitWidth); // Min = Next(Max) return; } @@ -243,14 +220,14 @@ } else { // No overlap on the right, just on the left. - return ConstantRange(RHS.getLower(), LHS.getUpper()); + return ConstantRange(RHS.Lower, LHS.Upper); } } else { // We don't overlap on the left side of RHS, see if we overlap on the right // of RHS... if (GT) { // Simple overlap... - return ConstantRange(LHS.getLower(), RHS.getUpper()); + return ConstantRange(LHS.Lower, RHS.Upper); } else { // No overlap... return ConstantRange(LHS.getType(), false); @@ -319,11 +296,9 @@ unsigned SrcTySize = Lower.getBitWidth(); unsigned DstTySize = Ty-getPrimitiveSizeInBits(); assert(SrcTySize DstTySize Not a value extension); - if (isFullSet()) { + if (isFullSet()) // Change a source full set into [0, 1 8*numbytes) -return ConstantRange(Constant::getNullValue(Ty), -
[llvm-commits] CVS: llvm/include/llvm/Support/ConstantRange.h
Changes in directory llvm/include/llvm/Support: ConstantRange.h updated: 1.16 - 1.17 --- Log message: For PR1205: http://llvm.org/PR1205 : First round of ConstantRange changes. This makes all CR constructors use only APInt and not use ConstantInt. Clients are adjusted accordingly. --- Diffs of the changes: (+5 -9) ConstantRange.h | 14 +- 1 files changed, 5 insertions(+), 9 deletions(-) Index: llvm/include/llvm/Support/ConstantRange.h diff -u llvm/include/llvm/Support/ConstantRange.h:1.16 llvm/include/llvm/Support/ConstantRange.h:1.17 --- llvm/include/llvm/Support/ConstantRange.h:1.16 Wed Feb 28 11:36:23 2007 +++ llvm/include/llvm/Support/ConstantRange.h Wed Feb 28 12:57:32 2007 @@ -51,22 +51,18 @@ /// Initialize a range to hold the single specified value. /// - ConstantRange(Constant *Value); + ConstantRange(const APInt Value); - /// Initialize a range of values explicitly... this will assert out if - /// Lower==Upper and Lower != Min or Max for its type, if the two constants - /// have different types, or if the constant are not integral values. - /// - ConstantRange(Constant *Lower, Constant *Upper); - - /// @brief Initialize a range of values explicitly. + /// @brief Initialize a range of values explicitly. This will assert out if + /// Lower==Upper and Lower != Min or Max value for its type. It will also + /// assert out if the two APInt's are not the same bit width. ConstantRange(const APInt Lower, const APInt Upper); /// Initialize a set of values that all satisfy the predicate with C. The /// predicate should be either an ICmpInst::Predicate or FCmpInst::Predicate /// value. /// @brief Get a range for a relation with a constant integral. - ConstantRange(unsigned short predicate, ConstantInt *C); + ConstantRange(unsigned short predicate, const APInt C); /// getLower - Return the lower value for this range... /// ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] ConstantRange
Chris, One last bugaboo on this. Right now, ConstantRange depends on VMCore because it needs Instructions.h to get the ICmp predicates. This is now the only reason for it to be in lib/Analysis. I would like to propose a change: 1. Put the bulk of ConstantRange into a new class, APRange in lib/Support. 2. Derive ConstantRange from APRange and add the one constructor that needs to use Instructions.h Does this make sense to you? If so, can you copy ConstantRange.cpp,v to APRange.cpp,v in lib/Support? Thanks, Reid. On Wed, 2007-02-28 at 10:21 -0800, Reid Spencer wrote: On Wed, 2007-02-28 at 10:11 -0800, Chris Lattner wrote: On Feb 28, 2007, at 8:29 AM, Reid Spencer wrote: Chris, I have converted ConstantRange to use APInt internally. This simplified it and got rid of some of the helper functions inside ConstantRange (because they have equivalents in APInt). Now I'm thinking that ConstantRange should completely avoid the use of ConstantInt in its API and replace all such uses with APInt. This would mean that the class could be implemented in lib/Support instead of lib/Analysis because it would no longer depend on lib/VMCore. Is this a desirable change? Very desirable! Or, do you want the interface to still work with ConstantInt? No need, the clients of ConstantRange can do the xlation. Okay, I will make it so in increments. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.224 - 1.225 --- Log message: Implement a convenience method to construct a ConstantInt directly from an APInt. The implied type is the integer type that corresponds to the bit width of the APInt. --- Diffs of the changes: (+4 -0) Constants.cpp |4 1 files changed, 4 insertions(+) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.224 llvm/lib/VMCore/Constants.cpp:1.225 --- llvm/lib/VMCore/Constants.cpp:1.224 Tue Feb 27 17:27:26 2007 +++ llvm/lib/VMCore/Constants.cpp Wed Feb 28 13:50:21 2007 @@ -216,6 +216,10 @@ return Slot = new ConstantInt(ITy, V); } +ConstantInt *ConstantInt::get(const APInt V) { + return ConstantInt::get(IntegerType::get(V.getBitWidth()), V); +} + //===--===// //ConstantFP //===--===// ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Support/ConstantRange.h
Changes in directory llvm/include/llvm/Support: ConstantRange.h updated: 1.17 - 1.18 --- Log message: For PR1205: http://llvm.org/PR1205 : Remove ConstantInt from ConstantRange interface and adjust its users to compensate. --- Diffs of the changes: (+9 -6) ConstantRange.h | 15 +-- 1 files changed, 9 insertions(+), 6 deletions(-) Index: llvm/include/llvm/Support/ConstantRange.h diff -u llvm/include/llvm/Support/ConstantRange.h:1.17 llvm/include/llvm/Support/ConstantRange.h:1.18 --- llvm/include/llvm/Support/ConstantRange.h:1.17 Wed Feb 28 12:57:32 2007 +++ llvm/include/llvm/Support/ConstantRange.h Wed Feb 28 13:57:34 2007 @@ -37,7 +37,6 @@ namespace llvm { class Constant; -class ConstantInt; class Type; class ConstantRange { @@ -66,11 +65,11 @@ /// getLower - Return the lower value for this range... /// - ConstantInt *getLower() const; + const APInt getLower() const { return Lower; } /// getUpper - Return the upper value for this range... /// - ConstantInt *getUpper() const; + const APInt getUpper() const { return Upper; } /// getType - Return the LLVM data type of this range. /// @@ -94,12 +93,16 @@ /// The isSigned parameter indicates whether the comparisons should be /// performed as if the values are signed or not. /// - bool contains(ConstantInt *Val, bool isSigned) const; + bool contains(const APInt Val, bool isSigned) const; /// getSingleElement - If this set contains a single element, return it, /// otherwise return null. /// - ConstantInt *getSingleElement() const; + const APInt *getSingleElement() const { +if (Upper == Lower + 1) + return Lower; +return 0; + } /// isSingleElement - Return true if this set contains exactly one member. /// @@ -120,7 +123,7 @@ /// subtract - Subtract the specified constant from the endpoints of this /// constant range. - ConstantRange subtract(ConstantInt *CI) const; + ConstantRange subtract(const APInt CI) const; /// intersectWith - Return the range that results from the intersection of /// this range with another range. The resultant range is pruned as much as ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Analysis/ScalarEvolution.h
Changes in directory llvm/include/llvm/Analysis: ScalarEvolution.h updated: 1.14 - 1.15 --- Log message: For PR1205: http://llvm.org/PR1205 : Remove ConstantInt from ConstantRange interface and adjust its users to compensate. --- Diffs of the changes: (+4 -0) ScalarEvolution.h |4 1 files changed, 4 insertions(+) Index: llvm/include/llvm/Analysis/ScalarEvolution.h diff -u llvm/include/llvm/Analysis/ScalarEvolution.h:1.14 llvm/include/llvm/Analysis/ScalarEvolution.h:1.15 --- llvm/include/llvm/Analysis/ScalarEvolution.h:1.14 Sat Dec 16 23:15:12 2006 +++ llvm/include/llvm/Analysis/ScalarEvolution.hWed Feb 28 13:57:34 2007 @@ -85,6 +85,10 @@ /// virtual const Type *getType() const = 0; +/// getBitWidth - Get the bit width of the type, if it has one, 0 otherwise. +/// +uint32_t getBitWidth() const; + /// replaceSymbolicValuesWithConcrete - If this SCEV internally references /// the symbolic value Sym, construct and return a new SCEV that produces /// the same value, but which uses the concrete value Conc instead of the ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp
Changes in directory llvm/lib/Transforms/Scalar: CorrelatedExprs.cpp updated: 1.53 - 1.54 --- Log message: For PR1205: http://llvm.org/PR1205 : Remove ConstantInt from ConstantRange interface and adjust its users to compensate. --- Diffs of the changes: (+4 -1) CorrelatedExprs.cpp |5 - 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp diff -u llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.53 llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.54 --- llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.53 Wed Feb 28 12:57:32 2007 +++ llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp Wed Feb 28 13:57:34 2007 @@ -1018,7 +1018,10 @@ // If we know that this value is a particular constant, set Replacement to // the constant... -Value *Replacement = VI.getBounds().getSingleElement(); +Value *Replacement = 0; +const APInt * Rplcmnt = VI.getBounds().getSingleElement(); +if (Rplcmnt) + Replacement = ConstantInt::get(*Rplcmnt); // If this value is not known to be some constant, figure out the lowest // rank value that it is known to be equal to (if anything). ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Analysis/ConstantRange.cpp ScalarEvolution.cpp
Changes in directory llvm/lib/Analysis: ConstantRange.cpp updated: 1.36 - 1.37 ScalarEvolution.cpp updated: 1.94 - 1.95 --- Log message: For PR1205: http://llvm.org/PR1205 : Remove ConstantInt from ConstantRange interface and adjust its users to compensate. --- Diffs of the changes: (+30 -45) ConstantRange.cpp | 27 +++ ScalarEvolution.cpp | 48 +++- 2 files changed, 30 insertions(+), 45 deletions(-) Index: llvm/lib/Analysis/ConstantRange.cpp diff -u llvm/lib/Analysis/ConstantRange.cpp:1.36 llvm/lib/Analysis/ConstantRange.cpp:1.37 --- llvm/lib/Analysis/ConstantRange.cpp:1.36Wed Feb 28 12:57:32 2007 +++ llvm/lib/Analysis/ConstantRange.cpp Wed Feb 28 13:57:34 2007 @@ -22,7 +22,6 @@ //===--===// #include llvm/Support/ConstantRange.h -#include llvm/Constants.h #include llvm/Instruction.h #include llvm/Instructions.h #include llvm/Type.h @@ -107,14 +106,6 @@ return IntegerType::get(Lower.getBitWidth()); } -ConstantInt *ConstantRange::getLower() const { - return ConstantInt::get(getType(), Lower); -} - -ConstantInt *ConstantRange::getUpper() const { - return ConstantInt::get(getType(), Upper); -} - /// isFullSet - Return true if this set contains all of the elements possible /// for this data-type bool ConstantRange::isFullSet() const { @@ -136,14 +127,6 @@ return Lower.ugt(Upper); } -/// getSingleElement - If this set contains a single element, return it, -/// otherwise return null. -ConstantInt *ConstantRange::getSingleElement() const { - if (Upper == Lower + 1) // Is it a single element range? -return ConstantInt::get(getType(), Lower); - return 0; -} - /// getSetSize - Return the number of elements in this set. /// APInt ConstantRange::getSetSize() const { @@ -161,14 +144,13 @@ /// contains - Return true if the specified value is in the set. /// -bool ConstantRange::contains(ConstantInt *Val, bool isSigned) const { +bool ConstantRange::contains(const APInt V, bool isSigned) const { if (Lower == Upper) { if (isFullSet()) return true; return false; } - const APInt V = Val-getValue(); if (!isWrappedSet(isSigned)) if (isSigned) return Lower.sle(V) V.slt(Upper); @@ -182,14 +164,11 @@ /// subtract - Subtract the specified constant from the endpoints of this /// constant range. -ConstantRange ConstantRange::subtract(ConstantInt *CI) const { - assert(CI-getType() == getType() - Cannot subtract from different type range or non-integer!); +ConstantRange ConstantRange::subtract(const APInt Val) const { + assert(Val.getBitWidth() == Lower.getBitWidth() Wrong bit width); // If the set is empty or full, don't modify the endpoints. if (Lower == Upper) return *this; - - const APInt Val = CI-getValue(); return ConstantRange(Lower - Val, Upper - Val); } Index: llvm/lib/Analysis/ScalarEvolution.cpp diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.94 llvm/lib/Analysis/ScalarEvolution.cpp:1.95 --- llvm/lib/Analysis/ScalarEvolution.cpp:1.94 Wed Feb 28 12:57:32 2007 +++ llvm/lib/Analysis/ScalarEvolution.cpp Wed Feb 28 13:57:34 2007 @@ -127,6 +127,12 @@ return ConstantRange(getType()); } +uint32_t SCEV::getBitWidth() const { + if (const IntegerType* ITy = dyn_castIntegerType(getType())) +return ITy-getBitWidth(); + return 0; +} + SCEVCouldNotCompute::SCEVCouldNotCompute() : SCEV(scCouldNotCompute) {} @@ -2320,7 +2326,7 @@ SCEVHandle Shifted = SCEVAddRecExpr::get(Operands, getLoop()); if (SCEVAddRecExpr *ShiftedAddRec = dyn_castSCEVAddRecExpr(Shifted)) return ShiftedAddRec-getNumIterationsInRange( - Range.subtract(SC-getValue()),isSigned); + Range.subtract(SC-getValue()-getValue()),isSigned); // This is strange and shouldn't happen. return new SCEVCouldNotCompute(); } @@ -2337,8 +2343,8 @@ // First check to see if the range contains zero. If not, the first // iteration exits. - ConstantInt *Zero = ConstantInt::get(getType(), 0); - if (!Range.contains(Zero, isSigned)) return SCEVConstant::get(Zero); + if (!Range.contains(APInt(getBitWidth(),0), isSigned)) +return SCEVConstant::get(ConstantInt::get(getType(),0)); if (isAffine()) { // If this is an affine expression then we have this situation: @@ -2347,29 +2353,27 @@ // Since we know that zero is in the range, we know that the upper value of // the range must be the first possible exit value. Also note that we // already checked for a full range. -ConstantInt *Upper = castConstantInt(Range.getUpper()); -ConstantInt *A = castSCEVConstant(getOperand(1))-getValue(); -ConstantInt *One = ConstantInt::get(getType(), 1); +const APInt Upper = Range.getUpper(); +APInt A =
Re: [llvm-commits] ConstantRange
On Feb 28, 2007, at 11:46 AM, Reid Spencer wrote: Chris, One last bugaboo on this. Right now, ConstantRange depends on VMCore because it needs Instructions.h to get the ICmp predicates. This is now the only reason for it to be in lib/Analysis. I would like to propose a change: 1. Put the bulk of ConstantRange into a new class, APRange in lib/Support. 2. Derive ConstantRange from APRange and add the one constructor that needs to use Instructions.h Does this make sense to you? If so, can you copy ConstantRange.cpp,v to APRange.cpp,v in lib/Support? Better yet: just have a global function (or method of ConstantInt) in VMCore that constructs the appropriate ConstantRange and returns it. -chris Thanks, Reid. On Wed, 2007-02-28 at 10:21 -0800, Reid Spencer wrote: On Wed, 2007-02-28 at 10:11 -0800, Chris Lattner wrote: On Feb 28, 2007, at 8:29 AM, Reid Spencer wrote: Chris, I have converted ConstantRange to use APInt internally. This simplified it and got rid of some of the helper functions inside ConstantRange (because they have equivalents in APInt). Now I'm thinking that ConstantRange should completely avoid the use of ConstantInt in its API and replace all such uses with APInt. This would mean that the class could be implemented in lib/Support instead of lib/Analysis because it would no longer depend on lib/VMCore. Is this a desirable change? Very desirable! Or, do you want the interface to still work with ConstantInt? No need, the clients of ConstantRange can do the xlation. Okay, I will make it so in increments. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.479 - 1.480 --- Log message: Chain is on second operand. --- Diffs of the changes: (+23 -4) LegalizeDAG.cpp | 27 +++ 1 files changed, 23 insertions(+), 4 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.479 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.480 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.479 Sat Feb 24 03:44:17 2007 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Wed Feb 28 14:43:58 2007 @@ -676,16 +676,13 @@ else Result = DAG.getConstant(0, TLI.getPointerTy()); break; - case ISD::EHSELECTION: case ISD::EXCEPTIONADDR: { Tmp1 = LegalizeOp(Node-getOperand(0)); MVT::ValueType VT = Node-getValueType(0); switch (TLI.getOperationAction(Node-getOpcode(), VT)) { default: assert(0 This action is not supported yet!); case TargetLowering::Expand: { -unsigned Reg = Node-getOpcode() == ISD::EXCEPTIONADDR ? - TLI.getExceptionAddressRegister() : - TLI.getExceptionSelectorRegister(); +unsigned Reg = TLI.getExceptionAddressRegister(); Result = DAG.getCopyFromReg(Tmp1, Reg, VT).getValue(Op.ResNo); } break; @@ -700,6 +697,28 @@ } } break; + case ISD::EHSELECTION: { +Tmp1 = LegalizeOp(Node-getOperand(0)); +Tmp2 = LegalizeOp(Node-getOperand(1)); +MVT::ValueType VT = Node-getValueType(0); +switch (TLI.getOperationAction(Node-getOpcode(), VT)) { +default: assert(0 This action is not supported yet!); +case TargetLowering::Expand: { +unsigned Reg = TLI.getExceptionSelectorRegister(); +Result = DAG.getCopyFromReg(Tmp2, Reg, VT).getValue(Op.ResNo); + } + break; +case TargetLowering::Custom: + Result = TLI.LowerOperation(Op, DAG); + if (Result.Val) break; + // Fall Thru +case TargetLowering::Legal: + Result = DAG.getNode(ISD::MERGE_VALUES, VT, DAG.getConstant(0, VT), Tmp2). + getValue(Op.ResNo); + break; +} +} +break; case ISD::AssertSext: case ISD::AssertZext: Tmp1 = LegalizeOp(Node-getOperand(0)); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/VMCore/Instructions.cpp
Changes in directory llvm/lib/VMCore: Instructions.cpp updated: 1.78 - 1.79 --- Log message: Provide an ICmpInst::makeConstantRange to generate a ConstantRange value from a predicate and an APInt. This is removed from ConstantRange class so that ConstantRange doesn't have to depend on lib/VMCore. --- Diffs of the changes: (+36 -0) Instructions.cpp | 36 1 files changed, 36 insertions(+) Index: llvm/lib/VMCore/Instructions.cpp diff -u llvm/lib/VMCore/Instructions.cpp:1.78 llvm/lib/VMCore/Instructions.cpp:1.79 --- llvm/lib/VMCore/Instructions.cpp:1.78 Fri Feb 23 18:55:48 2007 +++ llvm/lib/VMCore/Instructions.cppWed Feb 28 16:00:54 2007 @@ -18,6 +18,7 @@ #include llvm/Function.h #include llvm/Instructions.h #include llvm/Support/CallSite.h +#include llvm/Support/ConstantRange.h using namespace llvm; unsigned CallSite::getCallingConv() const { @@ -2217,6 +2218,41 @@ } } +/// Initialize a set of values that all satisfy the condition with C. +/// +ConstantRange +ICmpInst::makeConstantRange(Predicate pred, const APInt C) { + APInt Lower(C); + APInt Upper(C); + uint32_t BitWidth = C.getBitWidth(); + switch (pred) { + default: assert(0 Invalid ICmp opcode to ConstantRange ctor!); + case ICmpInst::ICMP_EQ: Upper++; break; + case ICmpInst::ICMP_NE: Lower++; break; + case ICmpInst::ICMP_ULT: Lower = APInt::getMinValue(BitWidth); break; + case ICmpInst::ICMP_SLT: Lower = APInt::getSignedMinValue(BitWidth); break; + case ICmpInst::ICMP_UGT: +Lower++; Upper = APInt::getMinValue(BitWidth);// Min = Next(Max) +break; + case ICmpInst::ICMP_SGT: +Lower++; Upper = APInt::getSignedMinValue(BitWidth); // Min = Next(Max) +break; + case ICmpInst::ICMP_ULE: +Lower = APInt::getMinValue(BitWidth); Upper++; +break; + case ICmpInst::ICMP_SLE: +Lower = APInt::getSignedMinValue(BitWidth); Upper++; +break; + case ICmpInst::ICMP_UGE: +Upper = APInt::getMinValue(BitWidth);// Min = Next(Max) +break; + case ICmpInst::ICMP_SGE: +Upper = APInt::getSignedMinValue(BitWidth); // Min = Next(Max) +break; + } + return ConstantRange(Lower, Upper); +} + FCmpInst::Predicate FCmpInst::getInversePredicate(Predicate pred) { switch (pred) { default: ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Instructions.h
Changes in directory llvm/include/llvm: Instructions.h updated: 1.62 - 1.63 --- Log message: Provide an ICmpInst::makeConstantRange to generate a ConstantRange value from a predicate and an APInt. This is removed from ConstantRange class so that ConstantRange doesn't have to depend on lib/VMCore. --- Diffs of the changes: (+6 -0) Instructions.h |6 ++ 1 files changed, 6 insertions(+) Index: llvm/include/llvm/Instructions.h diff -u llvm/include/llvm/Instructions.h:1.62 llvm/include/llvm/Instructions.h:1.63 --- llvm/include/llvm/Instructions.h:1.62 Fri Feb 23 18:55:48 2007 +++ llvm/include/llvm/Instructions.hWed Feb 28 16:00:54 2007 @@ -24,6 +24,8 @@ class ConstantInt; class PointerType; class VectorType; +class ConstantRange; +class APInt; //===--===// // AllocationInst Class @@ -536,6 +538,10 @@ /// @brief Determine if the predicate is signed. static bool isSignedPredicate(Predicate pred); + /// Initialize a set of values that all satisfy the predicate with C. + /// @brief Make a ConstantRange for a relation with a constant value. + static ConstantRange makeConstantRange(Predicate pred, const APInt C); + /// Exchange the two operands to this instruction in such a way that it does /// not modify the semantics of the instruction. The predicate value may be /// changed to retain the same result if the predicate is order dependent ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Support/ConstantRange.h
Changes in directory llvm/include/llvm/Support: ConstantRange.h updated: 1.18 - 1.19 --- Log message: Move ConstantRange class to lib/Support from lib/Analysis and make its interface not depend on Type or ICmpInst. --- Diffs of the changes: (+7 -15) ConstantRange.h | 22 +++--- 1 files changed, 7 insertions(+), 15 deletions(-) Index: llvm/include/llvm/Support/ConstantRange.h diff -u llvm/include/llvm/Support/ConstantRange.h:1.18 llvm/include/llvm/Support/ConstantRange.h:1.19 --- llvm/include/llvm/Support/ConstantRange.h:1.18 Wed Feb 28 13:57:34 2007 +++ llvm/include/llvm/Support/ConstantRange.h Wed Feb 28 16:02:48 2007 @@ -36,17 +36,15 @@ #include iosfwd namespace llvm { -class Constant; -class Type; class ConstantRange { APInt Lower, Upper; static ConstantRange intersect1Wrapped(const ConstantRange LHS, const ConstantRange RHS, bool sign); public: - /// Initialize a full (the default) or empty set for the specified type. + /// Initialize a full (the default) or empty set for the specified bit width. /// - ConstantRange(const Type *Ty, bool isFullSet = true); + ConstantRange(uint32_t BitWidth, bool isFullSet = true); /// Initialize a range to hold the single specified value. /// @@ -57,12 +55,6 @@ /// assert out if the two APInt's are not the same bit width. ConstantRange(const APInt Lower, const APInt Upper); - /// Initialize a set of values that all satisfy the predicate with C. The - /// predicate should be either an ICmpInst::Predicate or FCmpInst::Predicate - /// value. - /// @brief Get a range for a relation with a constant integral. - ConstantRange(unsigned short predicate, const APInt C); - /// getLower - Return the lower value for this range... /// const APInt getLower() const { return Lower; } @@ -71,9 +63,9 @@ /// const APInt getUpper() const { return Upper; } - /// getType - Return the LLVM data type of this range. + /// getBitWidth - get the bit width of this ConstantRange /// - const Type *getType() const; + uint32_t getBitWidth() const { return Lower.getBitWidth(); } /// isFullSet - Return true if this set contains all of the elements possible /// for this data-type @@ -144,14 +136,14 @@ /// zeroExtend - Return a new range in the specified integer type, which must /// be strictly larger than the current type. The returned range will /// correspond to the possible range of values if the source range had been - /// zero extended. - ConstantRange zeroExtend(const Type *Ty) const; + /// zero extended to BitWidth. + ConstantRange zeroExtend(uint32_t BitWidth) const; /// truncate - Return a new range in the specified integer type, which must be /// strictly smaller than the current type. The returned range will /// correspond to the possible range of values if the source range had been /// truncated to the specified type. - ConstantRange truncate(const Type *Ty) const; + ConstantRange truncate(uint32_t BitWidth) const; /// print - Print out the bounds to a stream... /// ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Support/ConstantRange.cpp
Changes in directory llvm/lib/Support: ConstantRange.cpp updated: 1.37 - 1.38 --- Log message: Move ConstantRange class to lib/Support from lib/Analysis and make its interface not depend on Type or ICmpInst. --- Diffs of the changes: (+20 -76) ConstantRange.cpp | 96 +++--- 1 files changed, 20 insertions(+), 76 deletions(-) Index: llvm/lib/Support/ConstantRange.cpp diff -u llvm/lib/Support/ConstantRange.cpp:1.37 llvm/lib/Support/ConstantRange.cpp:1.38 --- llvm/lib/Support/ConstantRange.cpp:1.37 Wed Feb 28 13:57:34 2007 +++ llvm/lib/Support/ConstantRange.cpp Wed Feb 28 16:02:48 2007 @@ -22,20 +22,14 @@ //===--===// #include llvm/Support/ConstantRange.h -#include llvm/Instruction.h -#include llvm/Instructions.h -#include llvm/Type.h -#include llvm/DerivedTypes.h #include llvm/Support/Streams.h #include ostream using namespace llvm; /// Initialize a full (the default) or empty set for the specified type. /// -ConstantRange::ConstantRange(const Type *Ty, bool Full) : - Lower(castIntegerType(Ty)-getBitWidth(), 0), - Upper(castIntegerType(Ty)-getBitWidth(), 0) { - uint32_t BitWidth = castIntegerType(Ty)-getBitWidth(); +ConstantRange::ConstantRange(uint32_t BitWidth, bool Full) : + Lower(BitWidth, 0), Upper(BitWidth, 0) { if (Full) Lower = Upper = APInt::getMaxValue(BitWidth); else @@ -56,66 +50,16 @@ Lower == Upper, but they aren't min or max value!); } -/// Initialize a set of values that all satisfy the condition with C. -/// -ConstantRange::ConstantRange(unsigned short ICmpOpcode, const APInt C) - : Lower(C.getBitWidth(), 0), Upper(C.getBitWidth(), 0) { - uint32_t BitWidth = C.getBitWidth(); - switch (ICmpOpcode) { - default: assert(0 Invalid ICmp opcode to ConstantRange ctor!); - case ICmpInst::ICMP_EQ: Lower = C; Upper = C + 1; return; - case ICmpInst::ICMP_NE: Upper = C; Lower = C + 1; return; - case ICmpInst::ICMP_ULT: -Lower = APInt::getMinValue(BitWidth); -Upper = C; -return; - case ICmpInst::ICMP_SLT: -Lower = APInt::getSignedMinValue(BitWidth); -Upper = C; -return; - case ICmpInst::ICMP_UGT: -Lower = C + 1; -Upper = APInt::getMinValue(BitWidth);// Min = Next(Max) -return; - case ICmpInst::ICMP_SGT: -Lower = C + 1; -Upper = APInt::getSignedMinValue(BitWidth); // Min = Next(Max) -return; - case ICmpInst::ICMP_ULE: -Lower = APInt::getMinValue(BitWidth); -Upper = C + 1; -return; - case ICmpInst::ICMP_SLE: -Lower = APInt::getSignedMinValue(BitWidth); -Upper = C + 1; -return; - case ICmpInst::ICMP_UGE: -Lower = C; -Upper = APInt::getMinValue(BitWidth);// Min = Next(Max) -return; - case ICmpInst::ICMP_SGE: -Lower = C; -Upper = APInt::getSignedMinValue(BitWidth); // Min = Next(Max) -return; - } -} - -/// getType - Return the LLVM data type of this range. -/// -const Type *ConstantRange::getType() const { - return IntegerType::get(Lower.getBitWidth()); -} - /// isFullSet - Return true if this set contains all of the elements possible /// for this data-type bool ConstantRange::isFullSet() const { - return Lower == Upper Lower == APInt::getMaxValue(Lower.getBitWidth()); + return Lower == Upper Lower == APInt::getMaxValue(getBitWidth()); } /// isEmptySet - Return true if this set contains no members. /// bool ConstantRange::isEmptySet() const { - return Lower == Upper Lower == APInt::getMinValue(Lower.getBitWidth()); + return Lower == Upper Lower == APInt::getMinValue(getBitWidth()); } /// isWrappedSet - Return true if this set wraps around the top of the range, @@ -131,11 +75,11 @@ /// APInt ConstantRange::getSetSize() const { if (isEmptySet()) -return APInt(Lower.getBitWidth(), 0); - if (getType() == Type::Int1Ty) { +return APInt(getBitWidth(), 0); + if (getBitWidth() == 1) { if (Lower != Upper) // One of T or F in the set... - return APInt(Lower.getBitWidth(), 1); -return APInt(Lower.getBitWidth(), 2); // Must be full set... + return APInt(2, 1); +return APInt(2, 2); // Must be full set... } // Simply subtract the bounds... @@ -165,7 +109,7 @@ /// subtract - Subtract the specified constant from the endpoints of this /// constant range. ConstantRange ConstantRange::subtract(const APInt Val) const { - assert(Val.getBitWidth() == Lower.getBitWidth() Wrong bit width); + assert(Val.getBitWidth() == getBitWidth() Wrong bit width); // If the set is empty or full, don't modify the endpoints. if (Lower == Upper) return *this; @@ -209,7 +153,7 @@ return ConstantRange(LHS.Lower, RHS.Upper); } else { // No overlap... - return ConstantRange(LHS.getType(), false); + return ConstantRange(LHS.getBitWidth(), false); } } } @@ -219,7 +163,8 @@ /// ConstantRange
[llvm-commits] CVS: llvm/lib/Analysis/ConstantRange.cpp
Changes in directory llvm/lib/Analysis: ConstantRange.cpp (r1.37) removed --- Log message: Move ConstantRange class to lib/Support from lib/Analysis and make its interface not depend on Type or ICmpInst. --- Diffs of the changes: (+0 -0) 0 files changed ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Analysis/ScalarEvolution.cpp
Changes in directory llvm/lib/Analysis: ScalarEvolution.cpp updated: 1.95 - 1.96 --- Log message: For PR1205: http://llvm.org/PR1205 : Adjust to changes in ConstantRange interface. --- Diffs of the changes: (+5 -4) ScalarEvolution.cpp |9 + 1 files changed, 5 insertions(+), 4 deletions(-) Index: llvm/lib/Analysis/ScalarEvolution.cpp diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.95 llvm/lib/Analysis/ScalarEvolution.cpp:1.96 --- llvm/lib/Analysis/ScalarEvolution.cpp:1.95 Wed Feb 28 13:57:34 2007 +++ llvm/lib/Analysis/ScalarEvolution.cpp Wed Feb 28 16:03:51 2007 @@ -124,7 +124,7 @@ const Type *Ty = getType(); assert(Ty-isInteger() Can't get range for a non-integer SCEV!); // Default to a full range if no better information is available. - return ConstantRange(getType()); + return ConstantRange(getBitWidth()); } uint32_t SCEV::getBitWidth() const { @@ -211,7 +211,7 @@ } ConstantRange SCEVTruncateExpr::getValueRange() const { - return getOperand()-getValueRange().truncate(getType()); + return getOperand()-getValueRange().truncate(getBitWidth()); } void SCEVTruncateExpr::print(std::ostream OS) const { @@ -237,7 +237,7 @@ } ConstantRange SCEVZeroExtendExpr::getValueRange() const { - return getOperand()-getValueRange().zeroExtend(getType()); + return getOperand()-getValueRange().zeroExtend(getBitWidth()); } void SCEVZeroExtendExpr::print(std::ostream OS) const { @@ -1572,7 +1572,8 @@ ConstantExpr::getBitCast(CompVal, RealTy)); if (CompVal) { // Form the constant range. - ConstantRange CompRange(Cond, CompVal-getValue()); + ConstantRange CompRange( + ICmpInst::makeConstantRange(Cond, CompVal-getValue())); SCEVHandle Ret = AddRec-getNumIterationsInRange(CompRange, false /*Always treat as unsigned range*/); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp
Changes in directory llvm/lib/Transforms/Scalar: CorrelatedExprs.cpp updated: 1.54 - 1.55 --- Log message: For PR1205: http://llvm.org/PR1205 : Adjust to changes in ConstantRange interface. --- Diffs of the changes: (+15 -9) CorrelatedExprs.cpp | 24 +++- 1 files changed, 15 insertions(+), 9 deletions(-) Index: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp diff -u llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.54 llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.55 --- llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.54 Wed Feb 28 13:57:34 2007 +++ llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp Wed Feb 28 16:03:51 2007 @@ -113,7 +113,8 @@ Value *Replacement; public: ValueInfo(const Type *Ty) - : Bounds(Ty-isInteger() ? Ty : Type::Int32Ty), Replacement(0) {} + : Bounds(Ty-isInteger() ? castIntegerType(Ty)-getBitWidth() : 32), + Replacement(0) {} // getBounds() - Return the constant bounds of the value... const ConstantRange getBounds() const { return Bounds; } @@ -1153,9 +1154,10 @@ // if (ConstantInt *C = dyn_castConstantInt(Op1)) { // Check to see if we already know the result of this comparison... - ConstantRange R = ConstantRange(predicate, C-getValue()); + ICmpInst::Predicate ipred = ICmpInst::Predicate(predicate); + ConstantRange R = ICmpInst::makeConstantRange(ipred, C-getValue()); ConstantRange Int = R.intersectWith(Op0VI-getBounds(), - ICmpInst::isSignedPredicate(ICmpInst::Predicate(predicate))); + ICmpInst::isSignedPredicate(ipred)); // If the intersection of the two ranges is empty, then the condition // could never be true! @@ -1199,10 +1201,12 @@ // if (ConstantInt *C = dyn_castConstantInt(Val)) if (Op = ICmpInst::FIRST_ICMP_PREDICATE -Op = ICmpInst::LAST_ICMP_PREDICATE) - if (ConstantRange(Op, C-getValue()).intersectWith(VI.getBounds(), - ICmpInst::isSignedPredicate(ICmpInst::Predicate(Op))).isEmptySet()) +Op = ICmpInst::LAST_ICMP_PREDICATE) { + ICmpInst::Predicate ipred = ICmpInst::Predicate(Op); + if (ICmpInst::makeConstantRange(ipred, C-getValue()).intersectWith( +VI.getBounds(), ICmpInst::isSignedPredicate(ipred)).isEmptySet()) return true; +} switch (Rel) { default: assert(0 Unknown Relationship code!); @@ -1257,10 +1261,12 @@ // if (ConstantInt *C = dyn_castConstantInt(Val)) if (Op = ICmpInst::FIRST_ICMP_PREDICATE -Op = ICmpInst::LAST_ICMP_PREDICATE) +Op = ICmpInst::LAST_ICMP_PREDICATE) { + ICmpInst::Predicate ipred = ICmpInst::Predicate(Op); VI.getBounds() = -ConstantRange(Op, C-getValue()).intersectWith(VI.getBounds(), - ICmpInst::isSignedPredicate(ICmpInst::Predicate(Op))); +ICmpInst::makeConstantRange(ipred, C-getValue()).intersectWith( +VI.getBounds(), ICmpInst::isSignedPredicate(ipred)); +} switch (Rel) { default: assert(0 Unknown prior value!); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/ARM/ARMRegisterInfo.cpp
Changes in directory llvm/lib/Target/ARM: ARMRegisterInfo.cpp updated: 1.75 - 1.76 --- Log message: Doh. ARM::PC is obvious a reserved register. --- Diffs of the changes: (+1 -0) ARMRegisterInfo.cpp |1 + 1 files changed, 1 insertion(+) Index: llvm/lib/Target/ARM/ARMRegisterInfo.cpp diff -u llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.75 llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.76 --- llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.75Tue Feb 27 18:59:19 2007 +++ llvm/lib/Target/ARM/ARMRegisterInfo.cpp Wed Feb 28 17:12:34 2007 @@ -315,6 +315,7 @@ BitVector ARMRegisterInfo::getReservedRegs(const MachineFunction MF) const { BitVector Reserved(getNumRegs()); Reserved.set(ARM::SP); + Reserved.set(ARM::PC); if (STI.isTargetDarwin() || hasFP(MF)) Reserved.set(FramePtr); // Some targets reserve R9. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
Changes in directory llvm/lib/Target/ARM: ARMConstantIslandPass.cpp updated: 1.31 - 1.32 --- Log message: Changes requested in review of last pass. Also pulled isThumb into a member, instead of resetting in every function that uses it. --- Diffs of the changes: (+142 -113) ARMConstantIslandPass.cpp | 255 +- 1 files changed, 142 insertions(+), 113 deletions(-) Index: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp diff -u llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.31 llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.32 --- llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.31 Wed Feb 28 12:41:22 2007 +++ llvm/lib/Target/ARM/ARMConstantIslandPass.cpp Wed Feb 28 17:20:38 2007 @@ -122,6 +122,7 @@ const TargetInstrInfo *TII; const ARMFunctionInfo *AFI; +bool isThumb; public: virtual bool runOnMachineFunction(MachineFunction Fn); @@ -140,6 +141,10 @@ void AdjustBBOffsetsAfter(MachineBasicBlock *BB, int delta); bool DecrementOldEntry(unsigned CPI, MachineInstr* CPEMI, unsigned Size); int LookForExistingCPEntry(CPUser U, unsigned UserOffset); +bool LookForWater(CPUserU, unsigned UserOffset, bool* PadNewWater, + MachineBasicBlock** NewMBB); +void CreateNewWater(unsigned CPUserIndex, unsigned UserOffset, + MachineBasicBlock** NewMBB); bool HandleConstantPoolUser(MachineFunction Fn, unsigned CPUserIndex); bool CPEIsInRange(MachineInstr *MI, unsigned UserOffset, MachineInstr *CPEMI, unsigned Disp, @@ -169,6 +174,7 @@ TII = Fn.getTarget().getInstrInfo(); AFI = Fn.getInfoARMFunctionInfo(); + isThumb = AFI-isThumbFunction(); HasFarJump = false; @@ -207,7 +213,7 @@ // If LR has been forced spilled and no far jumps (i.e. BL) has been issued. // Undo the spill / restore of LR if possible. - if (!HasFarJump AFI-isLRForceSpilled() AFI-isThumbFunction()) + if (!HasFarJump AFI-isLRForceSpilled() isThumb) MadeChange |= UndoLRSpillRestore(); BBSizes.clear(); @@ -413,7 +419,7 @@ // In thumb mode, if this block is a constpool island, pessimistically // assume it needs to be padded by two byte so it's aligned on 4 byte // boundary. -if (AFI-isThumbFunction() +if (isThumb !MBB.empty() MBB.begin()-getOpcode() == ARM::CONSTPOOL_ENTRY) MBBSize += 2; @@ -478,7 +484,6 @@ /// account for this change and returns the newly created block. MachineBasicBlock *ARMConstantIslands::SplitBlockBeforeInstr(MachineInstr *MI) { MachineBasicBlock *OrigBB = MI-getParent(); - bool isThumb = AFI-isThumbFunction(); // Create a new MBB for the code after the OrigBB. MachineBasicBlock *NewBB = new MachineBasicBlock(OrigBB-getBasicBlock()); @@ -579,7 +584,6 @@ bool ARMConstantIslands::WaterIsInRange(unsigned UserOffset, MachineBasicBlock* Water, unsigned MaxDisp) { - bool isThumb = AFI-isThumbFunction(); unsigned CPEOffset = BBOffsets[Water-getNumber()] + BBSizes[Water-getNumber()]; // If the Water is a constpool island, it has already been aligned. @@ -599,7 +603,6 @@ unsigned MaxDisp, bool DoDump) { // In thumb mode, pessimistically assumes the .align 2 before the first CPE // in the island adds two byte padding. - bool isThumb = AFI-isThumbFunction(); unsigned AlignAdj = isThumb ? 2 : 0; unsigned CPEOffset = GetOffsetOf(CPEMI) + AlignAdj; @@ -728,46 +731,22 @@ return (Opc == ARM::tB) ? ((110)-1)*2 : ((123)-1)*4; } -/// HandleConstantPoolUser - Analyze the specified user, checking to see if it -/// is out-of-range. If so, pick it up the constant pool value and move it some -/// place in-range. Return true if we changed any addresses (thus must run -/// another pass of branch lengthening), false otherwise. -bool ARMConstantIslands::HandleConstantPoolUser(MachineFunction Fn, -unsigned CPUserIndex){ - CPUser U = CPUsers[CPUserIndex]; - MachineInstr *UserMI = U.MI; - MachineInstr *CPEMI = U.CPEMI; - unsigned CPI = CPEMI-getOperand(1).getConstantPoolIndex(); - unsigned Size = CPEMI-getOperand(2).getImm(); - bool isThumb = AFI-isThumbFunction(); - MachineBasicBlock *NewMBB; - // Compute this only once, it's expensive - unsigned UserOffset = GetOffsetOf(UserMI) + (isThumb ? 4 : 8); - - // See if the current entry is within range, or there is a clone of it - // in range. - int result = LookForExistingCPEntry(U, UserOffset); - if (result==1) return false; - else if (result==2) return true; - - // No existing clone of this CPE is within range. - // We will be generating a new clone. Get a UID for it. - unsigned ID = NextUID++; +/// LookForWater - look for an existing entry in the WaterList in which +/// we can place the CPE referenced from U so it's within range of U's MI. +///
[llvm-commits] CVS: llvm/lib/Analysis/ScalarEvolution.cpp
Changes in directory llvm/lib/Analysis: ScalarEvolution.cpp updated: 1.96 - 1.97 --- Log message: For PR1205: http://llvm.org/PR1205 : Make GetConstantFactor compute its result using an APInt. --- Diffs of the changes: (+20 -16) ScalarEvolution.cpp | 36 1 files changed, 20 insertions(+), 16 deletions(-) Index: llvm/lib/Analysis/ScalarEvolution.cpp diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.96 llvm/lib/Analysis/ScalarEvolution.cpp:1.97 --- llvm/lib/Analysis/ScalarEvolution.cpp:1.96 Wed Feb 28 16:03:51 2007 +++ llvm/lib/Analysis/ScalarEvolution.cpp Wed Feb 28 17:31:17 2007 @@ -1328,31 +1328,33 @@ /// GetConstantFactor - Determine the largest constant factor that S has. For /// example, turn {4,+,8} - 4.(S umod result) should always equal zero. -static uint64_t GetConstantFactor(SCEVHandle S) { +static APInt GetConstantFactor(SCEVHandle S) { if (SCEVConstant *C = dyn_castSCEVConstant(S)) { -if (uint64_t V = C-getValue()-getZExtValue()) +APInt V = C-getValue()-getValue(); +if (!V.isMinValue()) return V; else // Zero is a multiple of everything. - return 1ULL (S-getType()-getPrimitiveSizeInBits()-1); + return APInt(C-getBitWidth(), 1).shl(C-getBitWidth()-1); } if (SCEVTruncateExpr *T = dyn_castSCEVTruncateExpr(S)) return GetConstantFactor(T-getOperand()) - castIntegerType(T-getType())-getBitMask(); + castIntegerType(T-getType())-getMask(); if (SCEVZeroExtendExpr *E = dyn_castSCEVZeroExtendExpr(S)) return GetConstantFactor(E-getOperand()); if (SCEVAddExpr *A = dyn_castSCEVAddExpr(S)) { // The result is the min of all operands. -uint64_t Res = GetConstantFactor(A-getOperand(0)); -for (unsigned i = 1, e = A-getNumOperands(); i != e Res 1; ++i) - Res = std::min(Res, GetConstantFactor(A-getOperand(i))); +APInt Res = GetConstantFactor(A-getOperand(0)); +for (unsigned i = 1, e = A-getNumOperands(); + i != e Res.ugt(APInt(Res.getBitWidth(),1)); ++i) + Res = APIntOps::umin(Res, GetConstantFactor(A-getOperand(i))); return Res; } if (SCEVMulExpr *M = dyn_castSCEVMulExpr(S)) { // The result is the product of all the operands. -uint64_t Res = GetConstantFactor(M-getOperand(0)); +APInt Res = GetConstantFactor(M-getOperand(0)); for (unsigned i = 1, e = M-getNumOperands(); i != e; ++i) Res *= GetConstantFactor(M-getOperand(i)); return Res; @@ -1362,15 +1364,16 @@ // For now, we just handle linear expressions. if (A-getNumOperands() == 2) { // We want the GCD between the start and the stride value. - uint64_t Start = GetConstantFactor(A-getOperand(0)); - if (Start == 1) return 1; - uint64_t Stride = GetConstantFactor(A-getOperand(1)); - return GreatestCommonDivisor64(Start, Stride); + APInt Start = GetConstantFactor(A-getOperand(0)); + if (Start == 1) +return APInt(A-getBitWidth(),1); + APInt Stride = GetConstantFactor(A-getOperand(1)); + return APIntOps::GreatestCommonDivisor(Start, Stride); } } // SCEVSDivExpr, SCEVUnknown. - return 1; + return APInt(S-getBitWidth(), 1); } /// createSCEV - We know that there is no SCEV for the specified value. @@ -1399,9 +1402,10 @@ // optimizations will transparently handle this case. if (ConstantInt *CI = dyn_castConstantInt(I-getOperand(1))) { SCEVHandle LHS = getSCEV(I-getOperand(0)); -uint64_t CommonFact = GetConstantFactor(LHS); -assert(CommonFact Common factor should at least be 1!); -if (CommonFact CI-getZExtValue()) { +APInt CommonFact = GetConstantFactor(LHS); +assert(!CommonFact.isMinValue() + Common factor should at least be 1!); +if (CommonFact.ugt(CI-getValue())) { // If the LHS is a multiple that is larger than the RHS, use +. return SCEVAddExpr::get(LHS, getSCEV(I-getOperand(1))); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] ConstantRange
Chris Lattner wrote: On Feb 28, 2007, at 11:46 AM, Reid Spencer wrote: Chris, One last bugaboo on this. Right now, ConstantRange depends on VMCore because it needs Instructions.h to get the ICmp predicates. This is now the only reason for it to be in lib/Analysis. I would like to propose a change: 1. Put the bulk of ConstantRange into a new class, APRange in lib/Support. 2. Derive ConstantRange from APRange and add the one constructor that needs to use Instructions.h Does this make sense to you? If so, can you copy ConstantRange.cpp,v to APRange.cpp,v in lib/Support? Better yet: just have a global function (or method of ConstantInt) in VMCore that constructs the appropriate ConstantRange and returns it. In my tree, I have an additional constructor for ConstantRange that takes an ICmpInst::Predicate and a ConstantRange. It returns the range where all of the values in the range satisfy the predicate against any of the values in the argument range. Where would a method like this fit, assuming that it doesn't belong in a pass? Nick ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] ConstantRange
Hi Nick, On Wed, 2007-02-28 at 19:29 -0500, Nick Lewycky wrote: In my tree, I have an additional constructor for ConstantRange that takes an ICmpInst::Predicate and a ConstantRange. It returns the range where all of the values in the range satisfy the predicate against any of the values in the argument range. Where would a method like this fit, assuming that it doesn't belong in a pass? I have removed the ConstantRange(Predicate, ConstantInt) constructor. You can now get that functionality from the ICmpInst class. Note sure that's the perfect place for it, but I figured since one needed to get a Predicate that ICmpInst would be included. Please note that ConstantRange is now in lib/Support, not lib/Analysis. Thus, it must not include anything from lib/VMCore, to avoid cyclic library dependencies. Net/net .. put it where you like it. I would vote for just putting it in PredSimplify for now. If some other pass needs it later on, we can move it. Code locality is a good thing and if predsimplify is the only client, it might as well define it. Reid. Nick ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h
Changes in directory llvm/include/llvm/CodeGen: MachineBasicBlock.h updated: 1.60 - 1.61 --- Log message: MachineBasicBlock fields should not be public. --- Diffs of the changes: (+0 -1) MachineBasicBlock.h |1 - 1 files changed, 1 deletion(-) Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.60 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.61 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.60 Thu Feb 22 10:39:03 2007 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Wed Feb 28 20:00:40 2007 @@ -58,7 +58,6 @@ class BasicBlock; class MachineBasicBlock { -public: typedef ilistMachineInstr Instructions; Instructions Insts; MachineBasicBlock *Prev, *Next; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h
Changes in directory llvm/include/llvm/CodeGen: LiveIntervalAnalysis.h updated: 1.75 - 1.76 --- Log message: Track all joined registers and eliminate unneeded kills after all joining are done. --- Diffs of the changes: (+10 -3) LiveIntervalAnalysis.h | 13 ++--- 1 files changed, 10 insertions(+), 3 deletions(-) Index: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h diff -u llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.75 llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.76 --- llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.75 Mon Feb 26 15:37:37 2007 +++ llvm/include/llvm/CodeGen/LiveIntervalAnalysis.hWed Feb 28 20:03:03 2007 @@ -57,6 +57,10 @@ BitVector allocatableRegs_; +/// JoinedLIs - Keep track which register intervals have been coalesced +/// with other intervals. +BitVector JoinedLIs; + public: struct CopyRec { MachineInstr *MI; @@ -119,8 +123,7 @@ } bool hasInterval(unsigned reg) const { - Reg2IntervalMap::const_iterator I = r2iMap_.find(reg); - return I != r2iMap_.end(); + return r2iMap_.count(reg); } /// getMBBStartIdx - Return the base index of the first instruction in the @@ -264,10 +267,14 @@ MachineInstr *lastRegisterUse(unsigned Reg, unsigned Start, unsigned End, MachineOperand *MOU); -/// unsetRegisterKill - Unset IsKill property of all uses of specific +/// unsetRegisterKill - Unset IsKill property of all uses of the specific /// register of the specific instruction. void unsetRegisterKill(MachineInstr *MI, unsigned Reg); +/// hasRegisterDef - True if the instruction defines the specific register. +/// +bool hasRegisterDef(MachineInstr *MI, unsigned Reg); + static LiveInterval createInterval(unsigned Reg); void removeInterval(unsigned Reg) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.217 - 1.218 --- Log message: Oops. --- Diffs of the changes: (+0 -1) LiveIntervalAnalysis.cpp |1 - 1 files changed, 1 deletion(-) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.217 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.218 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.217 Wed Feb 28 20:03:03 2007 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Feb 28 20:05:35 2007 @@ -988,7 +988,6 @@ DOUT \n\t\tJoined. Result = ; DestInt.print(DOUT, mri_); DOUT \n; -#if 1 // Remember these liveintervals have been joined. JoinedLIs.set(repSrcReg - MRegisterInfo::FirstVirtualRegister); if (MRegisterInfo::isVirtualRegister(repDstReg)) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/CodeGen/RegisterScavenging.h
Changes in directory llvm/include/llvm/CodeGen: RegisterScavenging.h updated: 1.5 - 1.6 --- Log message: Clean up interface. --- Diffs of the changes: (+3 -14) RegisterScavenging.h | 17 +++-- 1 files changed, 3 insertions(+), 14 deletions(-) Index: llvm/include/llvm/CodeGen/RegisterScavenging.h diff -u llvm/include/llvm/CodeGen/RegisterScavenging.h:1.5 llvm/include/llvm/CodeGen/RegisterScavenging.h:1.6 --- llvm/include/llvm/CodeGen/RegisterScavenging.h:1.5 Tue Feb 27 16:58:43 2007 +++ llvm/include/llvm/CodeGen/RegisterScavenging.h Wed Feb 28 20:18:06 2007 @@ -45,16 +45,9 @@ RegScavenger(MachineBasicBlock *mbb) : MBB(mbb), NumPhysRegs(0), Tracking(false) {}; - /// Init - Initialize the states. - /// - void init(MachineBasicBlock *mbb); - - /// Reset - Discard previous states and re-initialize the states given for - /// the specific basic block. - void reset(MachineBasicBlock *mbb) { -clear(); -init(mbb); - } + /// enterBasicBlock - Start tracking liveness from the begin of the specific + /// basic block. + void enterBasicBlock(MachineBasicBlock *mbb); /// forward / backward - Move the internal MBB iterator and update register /// states. @@ -91,10 +84,6 @@ bool ExCalleeSaved = false) const; private: - /// clear - Clear states. - /// - void clear(); - /// CalleeSavedrRegs - A bitvector of callee saved registers for the target. /// BitVector CalleeSavedRegs; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/RegisterScavenging.cpp
Changes in directory llvm/lib/CodeGen: RegisterScavenging.cpp updated: 1.7 - 1.8 --- Log message: Interface clean up. --- Diffs of the changes: (+7 -13) RegisterScavenging.cpp | 20 +++- 1 files changed, 7 insertions(+), 13 deletions(-) Index: llvm/lib/CodeGen/RegisterScavenging.cpp diff -u llvm/lib/CodeGen/RegisterScavenging.cpp:1.7 llvm/lib/CodeGen/RegisterScavenging.cpp:1.8 --- llvm/lib/CodeGen/RegisterScavenging.cpp:1.7 Tue Feb 27 16:58:43 2007 +++ llvm/lib/CodeGen/RegisterScavenging.cpp Wed Feb 28 20:19:39 2007 @@ -25,7 +25,7 @@ #include llvm/ADT/STLExtras.h using namespace llvm; -void RegScavenger::init(MachineBasicBlock *mbb) { +void RegScavenger::enterBasicBlock(MachineBasicBlock *mbb) { const MachineFunction MF = *mbb-getParent(); const TargetMachine TM = MF.getTarget(); const MRegisterInfo *RegInfo = TM.getRegisterInfo(); @@ -35,9 +35,11 @@ if (!MBB) { NumPhysRegs = RegInfo-getNumRegs(); -ReservedRegs = RegInfo-getReservedRegs(MF); RegStates.resize(NumPhysRegs); +// Create reserved registers bitvector. +ReservedRegs = RegInfo-getReservedRegs(MF); + // Create callee-saved registers bitvector. CalleeSavedRegs.resize(NumPhysRegs); const unsigned *CSRegs = RegInfo-getCalleeSavedRegs(); @@ -51,7 +53,7 @@ // All registers started out unused. RegStates.set(); - // Create reserved registers bitvector. + // Reserved registers are always used. RegStates ^= ReservedRegs; // Live-in registers are in use. @@ -59,6 +61,8 @@ for (MachineBasicBlock::const_livein_iterator I = MBB-livein_begin(), E = MBB-livein_end(); I != E; ++I) setUsed(*I); + + Tracking = false; } void RegScavenger::forward() { @@ -168,13 +172,3 @@ int Reg = RegStatesCopy.find_first(); return (Reg == -1) ? 0 : Reg; } - -void RegScavenger::clear() { - if (MBB) { -MBBI = MBB-end(); -MBB = NULL; - } - - Tracking = false; - RegStates.clear(); -} ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h
Changes in directory llvm/include/llvm: DerivedTypes.h updated: 1.84 - 1.85 --- Log message: Add an IntegerType::getMask() method to get an APInt mask for the type. --- Diffs of the changes: (+8 -0) DerivedTypes.h |8 1 files changed, 8 insertions(+) Index: llvm/include/llvm/DerivedTypes.h diff -u llvm/include/llvm/DerivedTypes.h:1.84 llvm/include/llvm/DerivedTypes.h:1.85 --- llvm/include/llvm/DerivedTypes.h:1.84 Wed Feb 14 21:39:17 2007 +++ llvm/include/llvm/DerivedTypes.hWed Feb 28 20:25:03 2007 @@ -19,6 +19,7 @@ #define LLVM_DERIVED_TYPES_H #include llvm/Type.h +#include llvm/ADT/APInt.h namespace llvm { @@ -108,6 +109,13 @@ return ~uint64_t(0UL) (64-getPrimitiveSizeInBits()); } + /// For example, this is 0xFF for an 8 bit integer, 0x for i16, etc. + /// @returns a bit mask with ones set for all the bits of this type. + /// @brief Get a bit mask for this type. + APInt getMask() const { +return APInt::getAllOnesValue(getBitWidth()); + } + /// This method determines if the width of this IntegerType is a power-of-2 /// in terms of 8 bit bytes. /// @returns true if this is a power-of-2 byte width. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/PrologEpilogInserter.cpp
Changes in directory llvm/lib/CodeGen: PrologEpilogInserter.cpp updated: 1.74 - 1.75 --- Log message: Interface clean up. --- Diffs of the changes: (+1 -1) PrologEpilogInserter.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp diff -u llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.74 llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.75 --- llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.74 Wed Feb 28 00:42:11 2007 +++ llvm/lib/CodeGen/PrologEpilogInserter.cpp Wed Feb 28 20:25:51 2007 @@ -445,7 +445,7 @@ RegScavenger *RS=MRI.requiresRegisterScavenging(Fn) ? new RegScavenger():NULL; for (MachineFunction::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) { -if (RS) RS-reset(BB); +if (RS) RS-enterBasicBlock(BB); for (MachineBasicBlock::iterator I = BB-begin(); I != BB-end(); ++I) { for (unsigned i = 0, e = I-getNumOperands(); i != e; ++i) if (I-getOperand(i).isFrameIndex()) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/VirtRegMap.cpp
Changes in directory llvm/lib/CodeGen: VirtRegMap.cpp updated: 1.100 - 1.101 --- Log message: A restore is promoted to copy (or deleted entirely), remove the kill from the last use of the targetted register. --- Diffs of the changes: (+4 -3) VirtRegMap.cpp |7 --- 1 files changed, 4 insertions(+), 3 deletions(-) Index: llvm/lib/CodeGen/VirtRegMap.cpp diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.100 llvm/lib/CodeGen/VirtRegMap.cpp:1.101 --- llvm/lib/CodeGen/VirtRegMap.cpp:1.100 Sun Feb 25 03:51:27 2007 +++ llvm/lib/CodeGen/VirtRegMap.cpp Wed Feb 28 20:27:30 2007 @@ -855,14 +855,15 @@ } else DOUT Removing now-noop copy: MI; - // Extend the live range of the MI that last kill the register if - // the next MI reuse it. + // Either way, the live range of the last kill of InReg has been + // extended. Remove its kill. MachineOperand *MOK = SSMI-findRegisterUseOperand(InReg, true); if (MOK NextMII != MBB.end()) { +MOK-unsetIsKill(); +// If NextMII uses InReg (must be the copy?), mark it killed. MachineOperand *MOU = NextMII-findRegisterUseOperand(InReg); if (MOU) { MOU-setIsKill(); - MOK-unsetIsKill(); Spills.UpdateLastUse(InReg, (*NextMII)); } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h
Changes in directory llvm/include/llvm: DerivedTypes.h updated: 1.85 - 1.86 --- Log message: Reduce #includage by taking a method out of line. --- Diffs of the changes: (+2 -4) DerivedTypes.h |6 ++ 1 files changed, 2 insertions(+), 4 deletions(-) Index: llvm/include/llvm/DerivedTypes.h diff -u llvm/include/llvm/DerivedTypes.h:1.85 llvm/include/llvm/DerivedTypes.h:1.86 --- llvm/include/llvm/DerivedTypes.h:1.85 Wed Feb 28 20:25:03 2007 +++ llvm/include/llvm/DerivedTypes.hWed Feb 28 22:02:06 2007 @@ -19,7 +19,6 @@ #define LLVM_DERIVED_TYPES_H #include llvm/Type.h -#include llvm/ADT/APInt.h namespace llvm { @@ -31,6 +30,7 @@ class PointerValType; class VectorValType; class IntegerValType; +class APInt; class DerivedType : public Type { friend class Type; @@ -112,9 +112,7 @@ /// For example, this is 0xFF for an 8 bit integer, 0x for i16, etc. /// @returns a bit mask with ones set for all the bits of this type. /// @brief Get a bit mask for this type. - APInt getMask() const { -return APInt::getAllOnesValue(getBitWidth()); - } + APInt getMask() const; /// This method determines if the width of this IntegerType is a power-of-2 /// in terms of 8 bit bytes. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] removal of isSigned from ConstantRange
This patch removes the isSigned parameter from the methods of ConstantRange. That concept was redundant with the wrapped set, except that wrapped set is a property of the ConstantRange. Patch attached. This updates users of ConstantRange to cope with the modified API. Nick Index: include/llvm/Support/ConstantRange.h === RCS file: /var/cvs/llvm/llvm/include/llvm/Support/ConstantRange.h,v retrieving revision 1.19 diff -u -t -d -u -p -5 -r1.19 ConstantRange.h --- include/llvm/Support/ConstantRange.h 28 Feb 2007 22:02:48 - 1.19 +++ include/llvm/Support/ConstantRange.h 1 Mar 2007 05:00:51 - @@ -38,11 +38,11 @@ namespace llvm { class ConstantRange { APInt Lower, Upper; static ConstantRange intersect1Wrapped(const ConstantRange LHS, - const ConstantRange RHS, bool sign); + const ConstantRange RHS); public: /// Initialize a full (the default) or empty set for the specified bit width. /// ConstantRange(uint32_t BitWidth, bool isFullSet = true); @@ -77,17 +77,15 @@ class ConstantRange { bool isEmptySet() const; /// isWrappedSet - Return true if this set wraps around the top of the range, /// for example: [100, 8) /// - bool isWrappedSet(bool isSigned) const; + bool isWrappedSet() const; /// contains - Return true if the specified value is in the set. - /// The isSigned parameter indicates whether the comparisons should be - /// performed as if the values are signed or not. /// - bool contains(const APInt Val, bool isSigned) const; + bool contains(const APInt Val) const; /// getSingleElement - If this set contains a single element, return it, /// otherwise return null. /// const APInt *getSingleElement() const { @@ -121,19 +119,19 @@ class ConstantRange { /// this range with another range. The resultant range is pruned as much as /// possible, but there may be cases where elements are included that are in /// one of the sets but not the other. For example: [100, 8) intersect [3, /// 120) yields [3, 120) /// - ConstantRange intersectWith(const ConstantRange CR, bool isSigned) const; + ConstantRange intersectWith(const ConstantRange CR) const; /// unionWith - Return the range that results from the union of this range /// with another range. The resultant range is guaranteed to include the /// elements of both sets, but may contain more. For example, [3, 9) union /// [12,15) is [3, 15), which includes 9, 10, and 11, which were not included /// in either set before. /// - ConstantRange unionWith(const ConstantRange CR, bool isSigned) const; + ConstantRange unionWith(const ConstantRange CR) const; /// zeroExtend - Return a new range in the specified integer type, which must /// be strictly larger than the current type. The returned range will /// correspond to the possible range of values if the source range had been /// zero extended to BitWidth. Index: lib/Support/ConstantRange.cpp === RCS file: /var/cvs/llvm/llvm/lib/Support/ConstantRange.cpp,v retrieving revision 1.38 diff -u -t -d -u -p -5 -r1.38 ConstantRange.cpp --- lib/Support/ConstantRange.cpp 28 Feb 2007 22:02:48 - 1.38 +++ lib/Support/ConstantRange.cpp 1 Mar 2007 05:00:51 - @@ -63,13 +63,11 @@ bool ConstantRange::isEmptySet() const { } /// isWrappedSet - Return true if this set wraps around the top of the range, /// for example: [100, 8) /// -bool ConstantRange::isWrappedSet(bool isSigned) const { - if (isSigned) -return Lower.sgt(Upper); +bool ConstantRange::isWrappedSet() const { return Lower.ugt(Upper); } /// getSetSize - Return the number of elements in this set. /// @@ -86,24 +84,16 @@ APInt ConstantRange::getSetSize() const return Upper - Lower; } /// contains - Return true if the specified value is in the set. /// -bool ConstantRange::contains(const APInt V, bool isSigned) const { - if (Lower == Upper) { -if (isFullSet()) - return true; -return false; - } +bool ConstantRange::contains(const APInt V) const { + if (Lower == Upper) +return isFullSet(); - if (!isWrappedSet(isSigned)) -if (isSigned) - return Lower.sle(V) V.slt(Upper); -else - return Lower.ule(V) V.ult(Upper); - if (isSigned) -return Lower.sle(V) || V.slt(Upper); + if (!isWrappedSet()) +return Lower.ule(V) V.ult(Upper); else return Lower.ule(V) || V.ult(Upper); } /// subtract - Subtract the specified constant from the endpoints of this @@ -120,21 +110,19 @@ ConstantRange ConstantRange::subtract(co // intersect1Wrapped - This helper function is used to intersect two ranges when // it is known that LHS is wrapped and RHS isn't. // ConstantRange ConstantRange::intersect1Wrapped(const ConstantRange LHS, - const
[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h
Changes in directory llvm/include/llvm/ADT: APInt.h updated: 1.30 - 1.31 --- Log message: Add a square root function. --- Diffs of the changes: (+3 -0) APInt.h |3 +++ 1 files changed, 3 insertions(+) Index: llvm/include/llvm/ADT/APInt.h diff -u llvm/include/llvm/ADT/APInt.h:1.30 llvm/include/llvm/ADT/APInt.h:1.31 --- llvm/include/llvm/ADT/APInt.h:1.30 Wed Feb 28 11:33:36 2007 +++ llvm/include/llvm/ADT/APInt.h Wed Feb 28 23:39:56 2007 @@ -686,6 +686,9 @@ double signedRoundToDouble() const { return roundToDouble(true); } + + /// @brief Compute the square root + APInt sqrt() const; }; inline bool operator==(uint64_t V1, const APInt V2) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Support/APInt.cpp
Changes in directory llvm/lib/Support: APInt.cpp updated: 1.59 - 1.60 --- Log message: Add a square root function. --- Diffs of the changes: (+87 -6) APInt.cpp | 93 ++ 1 files changed, 87 insertions(+), 6 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.59 llvm/lib/Support/APInt.cpp:1.60 --- llvm/lib/Support/APInt.cpp:1.59 Wed Feb 28 11:34:32 2007 +++ llvm/lib/Support/APInt.cpp Wed Feb 28 23:39:56 2007 @@ -1015,7 +1015,7 @@ if (shiftAmt APINT_BITS_PER_WORD) { uint64_t carry = 0; for (int i = getNumWords()-1; i = 0; --i) { - val[i] = pVal[i] shiftAmt | carry; + val[i] = (pVal[i] shiftAmt) | carry; carry = pVal[i] (APINT_BITS_PER_WORD - shiftAmt); } return APInt(val, BitWidth).clearUnusedBits(); @@ -1037,8 +1037,8 @@ // Shift the low order words uint32_t breakWord = getNumWords() - offset -1; for (uint32_t i = 0; i breakWord; ++i) -val[i] = pVal[i+offset] wordShift | - pVal[i+offset+1] (APINT_BITS_PER_WORD - wordShift); +val[i] = (pVal[i+offset] wordShift) | + (pVal[i+offset+1] (APINT_BITS_PER_WORD - wordShift)); // Shift the break word. uint32_t SignBit = APINT_BITS_PER_WORD - (BitWidth % APINT_BITS_PER_WORD); val[breakWord] = uint64_t( @@ -1072,7 +1072,7 @@ if (shiftAmt APINT_BITS_PER_WORD) { uint64_t carry = 0; for (int i = getNumWords()-1; i = 0; --i) { - val[i] = pVal[i] shiftAmt | carry; + val[i] = (pVal[i] shiftAmt) | carry; carry = pVal[i] (APINT_BITS_PER_WORD - shiftAmt); } return APInt(val, BitWidth).clearUnusedBits(); @@ -1094,8 +1094,8 @@ // Shift the low order words uint32_t breakWord = getNumWords() - offset -1; for (uint32_t i = 0; i breakWord; ++i) -val[i] = pVal[i+offset] wordShift | - pVal[i+offset+1] (APINT_BITS_PER_WORD - wordShift); +val[i] = (pVal[i+offset] wordShift) | + (pVal[i+offset+1] (APINT_BITS_PER_WORD - wordShift)); // Shift the break word. val[breakWord] = pVal[breakWord+offset] wordShift; @@ -1158,6 +1158,87 @@ return APInt(val, BitWidth).clearUnusedBits(); } + +// Square Root - this method computes and returns the square root of this. +// Three mechanisms are used for computation. For small values (= 5 bits), +// a table lookup is done. This gets some performance for common cases. For +// values using less than 52 bits, the value is converted to double and then +// the libc sqrt function is called. The result is rounded and then converted +// back to a uint64_t which is then used to construct the result. Finally, +// the Babylonian method for computing square roots is used. +APInt APInt::sqrt() const { + + // Determine the magnitude of the value. + uint32_t magnitude = getActiveBits(); + + // Use a fast table for some small values. This also gets rid of some + // rounding errors in libc sqrt for small values. + if (magnitude = 5) { +uint64_t result = 0; +switch (isSingleWord() ? VAL : pVal[0]) { + case 0 : break; + case 1 : case 2 : result = 1; break; + case 3 : case 4 : case 5: case 6: result = 2; break; + case 7 : case 8 : case 9: case 10: case 11: case 12: +result = 3; break; + case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: +result = 4; break; + case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: + case 29: case 30: result = 5; break; + case 31: result = 6; break; +} +return APInt(BitWidth, result); + } + + // If the magnitude of the value fits in less than 52 bits (the precision of + // an IEEE double precision floating point value), then we can use the + // libc sqrt function which will probably use a hardware sqrt computation. + // This should be faster than the algorithm below. + if (magnitude 52) +return APInt(BitWidth, + uint64_t(::round(::sqrt(double(isSingleWord()?VAL:pVal[0]); + + // Okay, all the short cuts are exhausted. We must compute it. The following + // is a classical Babylonian method for computing the square root. This code + // was adapted to APINt from a wikipedia article on such computations. + // See http://www.wikipedia.org/ and go to the page named + // Calculate_an_integer_square_root. + uint32_t nbits = BitWidth, i = 4; + APInt testy(BitWidth, 16); + APInt x_old(BitWidth, 1); + APInt x_new(BitWidth, 0); + APInt two(BitWidth, 2); + + // Select a good starting value using binary logarithms. + for (;; i += 2, testy = testy.shl(2)) +if (i = nbits || this-ule(testy)) { + x_old = x_old.shl(i / 2); + break; +} + + // Use the Babylonian method to arrive at the integer square root: + for (;;) { +x_new = (this-udiv(x_old) + x_old).udiv(two); +if (x_old.ule(x_new)) + break; +x_old = x_new; + } + + // Make sure we return the closest
[llvm-commits] CVS: llvm-test/SingleSource/Makefile.singlesrc
Changes in directory llvm-test/SingleSource: Makefile.singlesrc updated: 1.36 - 1.37 --- Log message: Put the -O2 first so that its possible to override it. --- Diffs of the changes: (+2 -2) Makefile.singlesrc |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-test/SingleSource/Makefile.singlesrc diff -u llvm-test/SingleSource/Makefile.singlesrc:1.36 llvm-test/SingleSource/Makefile.singlesrc:1.37 --- llvm-test/SingleSource/Makefile.singlesrc:1.36 Wed Feb 14 12:00:36 2007 +++ llvm-test/SingleSource/Makefile.singlesrc Thu Mar 1 00:14:14 2007 @@ -34,10 +34,10 @@ # FIXME: LIBS should be specified, not hardcoded to -lm Output/%.native: $(SourceDir)/%.c Output/.dir - -$(CC) $(CFLAGS) -O2 $(TARGET_FLAGS) $ -lm -o $@ $(LDFLAGS) + -$(CC) -O2 $(CFLAGS) $(TARGET_FLAGS) $ -lm -o $@ $(LDFLAGS) Output/%.native: $(SourceDir)/%.cpp Output/.dir - -$(CXX) $(CXXFLAGS) -O2 $(TARGET_FLAGS) $ -lm -o $@ $(LDFLAGS) + -$(CXX) -O2 $(CXXFLAGS) $(TARGET_FLAGS) $ -lm -o $@ $(LDFLAGS) bugpoint-gccas bugpoint-opt bugpoint-llvm-ld bugpoint-gccld bugpoint-jit bugpoint-llc bugpoint-llc-beta: ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp
+ // Use a fast table for some small values. This also gets rid of some + // rounding errors in libc sqrt for small values. + if (magnitude = 5) { Please use a real table, not a switch, for this. It will be smaller (codesize) and faster. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Analysis/ScalarEvolution.cpp
Changes in directory llvm/lib/Analysis: ScalarEvolution.cpp updated: 1.97 - 1.98 --- Log message: APIntify various computations in ScalarEvolution --- Diffs of the changes: (+52 -55) ScalarEvolution.cpp | 107 +--- 1 files changed, 52 insertions(+), 55 deletions(-) Index: llvm/lib/Analysis/ScalarEvolution.cpp diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.97 llvm/lib/Analysis/ScalarEvolution.cpp:1.98 --- llvm/lib/Analysis/ScalarEvolution.cpp:1.97 Wed Feb 28 17:31:17 2007 +++ llvm/lib/Analysis/ScalarEvolution.cpp Thu Mar 1 01:25:48 2007 @@ -1176,7 +1176,7 @@ /// in the header of its containing loop, we know the loop executes a /// constant number of times, and the PHI node is just a recurrence /// involving constants, fold it. -Constant *getConstantEvolutionLoopExitValue(PHINode *PN, uint64_t Its, +Constant *getConstantEvolutionLoopExitValue(PHINode *PN, const APInt Its, const Loop *L); }; } @@ -1729,7 +1729,7 @@ // Evaluate the condition for this iteration. Result = ConstantExpr::getICmp(predicate, Result, RHS); if (!isaConstantInt(Result)) break; // Couldn't decide for sure -if (castConstantInt(Result)-getZExtValue() == false) { +if (castConstantInt(Result)-getValue().isMinValue()) { #if 0 cerr \n***\n*** Computed loop count *ItCst \n*** From global *GV *** BB: *L-getHeader() @@ -1824,13 +1824,13 @@ /// constant number of times, and the PHI node is just a recurrence /// involving constants, fold it. Constant *ScalarEvolutionsImpl:: -getConstantEvolutionLoopExitValue(PHINode *PN, uint64_t Its, const Loop *L) { +getConstantEvolutionLoopExitValue(PHINode *PN, const APInt Its, const Loop *L){ std::mapPHINode*, Constant*::iterator I = ConstantEvolutionLoopExitValue.find(PN); if (I != ConstantEvolutionLoopExitValue.end()) return I-second; - if (Its MaxBruteForceIterations) + if (Its.ugt(APInt(Its.getBitWidth(),MaxBruteForceIterations))) return ConstantEvolutionLoopExitValue[PN] = 0; // Not going to evaluate it. Constant *RetVal = ConstantEvolutionLoopExitValue[PN]; @@ -1850,11 +1850,11 @@ return RetVal = 0; // Not derived from same PHI. // Execute the loop symbolically to determine the exit value. - unsigned IterationNum = 0; - unsigned NumIterations = Its; - if (NumIterations != Its) -return RetVal = 0; // More than 2^32 iterations?? + if (Its.getActiveBits() = 32) +return RetVal = 0; // More than 2^32-1 iterations?? Not doing it! + unsigned NumIterations = Its.getZExtValue(); // must be in range + unsigned IterationNum = 0; for (Constant *PHIVal = StartCST; ; ++IterationNum) { if (IterationNum == NumIterations) return RetVal = PHIVal; // Got exit value! @@ -1904,7 +1904,7 @@ // Couldn't symbolically evaluate. if (!CondVal) return UnknownValue; -if (CondVal-getZExtValue() == uint64_t(ExitWhen)) { +if (CondVal-getValue() == uint64_t(ExitWhen)) { ConstantEvolutionLoopExitValue[PN] = PHIVal; ++NumBruteForceTripCountsComputed; return SCEVConstant::get(ConstantInt::get(Type::Int32Ty, IterationNum)); @@ -1946,7 +1946,7 @@ // this is a constant evolving PHI node, get the final value at // the specified iteration number. Constant *RV = getConstantEvolutionLoopExitValue(PN, - ICC-getValue()-getZExtValue(), + ICC-getValue()-getValue(), LI); if (RV) return SCEVUnknown::get(RV); } @@ -2063,57 +2063,54 @@ static std::pairSCEVHandle,SCEVHandle SolveQuadraticEquation(const SCEVAddRecExpr *AddRec) { assert(AddRec-getNumOperands() == 3 This is not a quadratic chrec!); - SCEVConstant *L = dyn_castSCEVConstant(AddRec-getOperand(0)); - SCEVConstant *M = dyn_castSCEVConstant(AddRec-getOperand(1)); - SCEVConstant *N = dyn_castSCEVConstant(AddRec-getOperand(2)); + SCEVConstant *LC = dyn_castSCEVConstant(AddRec-getOperand(0)); + SCEVConstant *MC = dyn_castSCEVConstant(AddRec-getOperand(1)); + SCEVConstant *NC = dyn_castSCEVConstant(AddRec-getOperand(2)); // We currently can only solve this if the coefficients are constants. - if (!L || !M || !N) { + if (!LC || !MC || !NC) { SCEV *CNC = new SCEVCouldNotCompute(); return std::make_pair(CNC, CNC); } - Constant *C = L-getValue(); - Constant *Two = ConstantInt::get(C-getType(), 2); - - // Convert from chrec coefficients to polynomial coefficients AX^2+BX+C - // The B coefficient is M-N/2 - Constant *B = ConstantExpr::getSub(M-getValue(), - ConstantExpr::getSDiv(N-getValue(), - Two)); - // The A coefficient is
[llvm-commits] CVS: llvm/lib/Target/ARM/ARMMachineFunctionInfo.h
Changes in directory llvm/lib/Target/ARM: ARMMachineFunctionInfo.h updated: 1.6 - 1.7 --- Log message: Switch from std::vectorbool to BitVector. --- Diffs of the changes: (+32 -12) ARMMachineFunctionInfo.h | 44 1 files changed, 32 insertions(+), 12 deletions(-) Index: llvm/lib/Target/ARM/ARMMachineFunctionInfo.h diff -u llvm/lib/Target/ARM/ARMMachineFunctionInfo.h:1.6 llvm/lib/Target/ARM/ARMMachineFunctionInfo.h:1.7 --- llvm/lib/Target/ARM/ARMMachineFunctionInfo.h:1.6Wed Feb 7 03:17:36 2007 +++ llvm/lib/Target/ARM/ARMMachineFunctionInfo.hThu Mar 1 01:52:44 2007 @@ -17,6 +17,7 @@ #include ARMSubtarget.h #include llvm/CodeGen/MachineFunction.h #include llvm/Target/TargetMachine.h +#include llvm/ADT/BitVector.h namespace llvm { @@ -41,7 +42,7 @@ bool LRForceSpilled; /// R3IsLiveIn - True if R3 is live in to this function. - /// + /// FIXME: Remove when register scavenger for Thumb is done. bool R3IsLiveIn; /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer @@ -68,9 +69,9 @@ /// GPRCS1Frames, GPRCS2Frames, DPRCSFrames - Keeps track of frame indices /// which belong to these spill areas. - std::vectorbool GPRCS1Frames; - std::vectorbool GPRCS2Frames; - std::vectorbool DPRCSFrames; + BitVector GPRCS1Frames; + BitVector GPRCS2Frames; + BitVector DPRCSFrames; /// JumpTableUId - Unique id for jumptables. /// @@ -82,14 +83,18 @@ VarArgsRegSaveSize(0), HasStackFrame(false), LRForceSpilled(false), R3IsLiveIn(false), FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), -GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), JumpTableUId(0) {} +GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), +GPRCS1Frames(32), GPRCS2Frames(32), DPRCSFrames(32), +JumpTableUId(0) {} ARMFunctionInfo(MachineFunction MF) : isThumb(MF.getTarget().getSubtargetARMSubtarget().isThumb()), VarArgsRegSaveSize(0), HasStackFrame(false), LRForceSpilled(false), R3IsLiveIn(false), FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), -GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), JumpTableUId(0) {} +GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), +GPRCS1Frames(32), GPRCS2Frames(32), DPRCSFrames(32), +JumpTableUId(0) {} bool isThumbFunction() const { return isThumb; } @@ -142,22 +147,37 @@ void addGPRCalleeSavedArea1Frame(int fi) { if (fi = 0) { - if (fi = (int)GPRCS1Frames.size()) -GPRCS1Frames.resize(fi+1); + int Size = GPRCS1Frames.size(); + if (fi = Size) { +Size *= 2; +if (fi = Size) + Size = fi+1; +GPRCS1Frames.resize(Size); + } GPRCS1Frames[fi] = true; } } void addGPRCalleeSavedArea2Frame(int fi) { if (fi = 0) { - if (fi = (int)GPRCS2Frames.size()) -GPRCS2Frames.resize(fi+1); + int Size = GPRCS2Frames.size(); + if (fi = Size) { +Size *= 2; +if (fi = Size) + Size = fi+1; +GPRCS2Frames.resize(Size); + } GPRCS2Frames[fi] = true; } } void addDPRCalleeSavedAreaFrame(int fi) { if (fi = 0) { - if (fi = (int)DPRCSFrames.size()) -DPRCSFrames.resize(fi+1); + int Size = DPRCSFrames.size(); + if (fi = Size) { +Size *= 2; +if (fi = Size) + Size = fi+1; +DPRCSFrames.resize(Size); + } DPRCSFrames[fi] = true; } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Support/ConstantRange.cpp
Changes in directory llvm/lib/Support: ConstantRange.cpp updated: 1.38 - 1.39 --- Log message: Remove the isSigned parameters from ConstantRange. It turns out they are not needed as the results are the same with or without it. Patch by Nicholas Lewycky. --- Diffs of the changes: (+23 -37) ConstantRange.cpp | 60 -- 1 files changed, 23 insertions(+), 37 deletions(-) Index: llvm/lib/Support/ConstantRange.cpp diff -u llvm/lib/Support/ConstantRange.cpp:1.38 llvm/lib/Support/ConstantRange.cpp:1.39 --- llvm/lib/Support/ConstantRange.cpp:1.38 Wed Feb 28 16:02:48 2007 +++ llvm/lib/Support/ConstantRange.cpp Thu Mar 1 01:54:15 2007 @@ -65,9 +65,7 @@ /// isWrappedSet - Return true if this set wraps around the top of the range, /// for example: [100, 8) /// -bool ConstantRange::isWrappedSet(bool isSigned) const { - if (isSigned) -return Lower.sgt(Upper); +bool ConstantRange::isWrappedSet() const { return Lower.ugt(Upper); } @@ -88,20 +86,12 @@ /// contains - Return true if the specified value is in the set. /// -bool ConstantRange::contains(const APInt V, bool isSigned) const { - if (Lower == Upper) { -if (isFullSet()) - return true; -return false; - } +bool ConstantRange::contains(const APInt V) const { + if (Lower == Upper) +return isFullSet(); - if (!isWrappedSet(isSigned)) -if (isSigned) - return Lower.sle(V) V.slt(Upper); -else - return Lower.ule(V) V.ult(Upper); - if (isSigned) -return Lower.sle(V) || V.slt(Upper); + if (!isWrappedSet()) +return Lower.ule(V) V.ult(Upper); else return Lower.ule(V) || V.ult(Upper); } @@ -122,17 +112,15 @@ // ConstantRange ConstantRange::intersect1Wrapped(const ConstantRange LHS, - const ConstantRange RHS, bool isSigned) { - assert(LHS.isWrappedSet(isSigned) !RHS.isWrappedSet(isSigned)); + const ConstantRange RHS) { + assert(LHS.isWrappedSet() !RHS.isWrappedSet()); // Check to see if we overlap on the Left side of RHS... // - bool LT = (isSigned ? RHS.Lower.slt(LHS.Upper) : RHS.Lower.ult(LHS.Upper)); - bool GT = (isSigned ? RHS.Upper.sgt(LHS.Lower) : RHS.Upper.ugt(LHS.Lower)); - if (LT) { + if (RHS.Lower.ult(LHS.Upper)) { // We do overlap on the left side of RHS, see if we overlap on the right of // RHS... -if (GT) { +if (RHS.Upper.ugt(LHS.Lower)) { // Ok, the result overlaps on both the left and right sides. See if the // resultant interval will be smaller if we wrap or not... // @@ -148,7 +136,7 @@ } else { // We don't overlap on the left side of RHS, see if we overlap on the right // of RHS... -if (GT) { +if (RHS.Upper.ugt(LHS.Lower)) { // Simple overlap... return ConstantRange(LHS.Lower, RHS.Upper); } else { @@ -161,8 +149,7 @@ /// intersectWith - Return the range that results from the intersection of this /// range with another range. /// -ConstantRange ConstantRange::intersectWith(const ConstantRange CR, - bool isSigned) const { +ConstantRange ConstantRange::intersectWith(const ConstantRange CR) const { assert(getBitWidth() == CR.getBitWidth() ConstantRange types don't agree!); // Handle common special cases @@ -171,26 +158,26 @@ if (isFullSet() || CR.isEmptySet()) return CR; - if (!isWrappedSet(isSigned)) { -if (!CR.isWrappedSet(isSigned)) { + if (!isWrappedSet()) { +if (!CR.isWrappedSet()) { using namespace APIntOps; - APInt L = isSigned ? smax(Lower, CR.Lower) : umax(Lower, CR.Lower); - APInt U = isSigned ? smin(Upper, CR.Upper) : umin(Upper, CR.Upper); + APInt L = umax(Lower, CR.Lower); + APInt U = umin(Upper, CR.Upper); - if (isSigned ? L.slt(U) : L.ult(U)) // If range isn't empty... + if (L.ult(U)) // If range isn't empty... return ConstantRange(L, U); else return ConstantRange(getBitWidth(), false);// Otherwise, empty set } else - return intersect1Wrapped(CR, *this, isSigned); + return intersect1Wrapped(CR, *this); } else { // We know this is wrapped... -if (!CR.isWrappedSet(isSigned)) - return intersect1Wrapped(*this, CR, isSigned); +if (!CR.isWrappedSet()) + return intersect1Wrapped(*this, CR); else { // Both ranges are wrapped... using namespace APIntOps; - APInt L = isSigned ? smax(Lower, CR.Lower) : umax(Lower, CR.Lower); - APInt U = isSigned ? smin(Upper, CR.Upper) : umin(Upper, CR.Upper); + APInt L = umax(Lower, CR.Lower); + APInt U = umin(Upper, CR.Upper); return ConstantRange(L, U); } } @@ -203,8 +190,7 @@ /// 15), which includes 9, 10, and 11, which were not included in either set /// before. /// -ConstantRange ConstantRange::unionWith(const ConstantRange CR, - bool