llvm.org GIT mirror llvm / e056781
Add variants of ult, ule, etc. which take a uint64_t RHS, for convenience. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100824 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
5 changed file(s) with 71 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
869869 /// @brief Unsigned less than comparison
870870 bool ult(const APInt& RHS) const;
871871
872 /// Regards both *this as an unsigned quantity and compares it with RHS for
873 /// the validity of the less-than relationship.
874 /// @returns true if *this < RHS when considered unsigned.
875 /// @brief Unsigned less than comparison
876 bool ult(uint64_t RHS) const {
877 return ult(APInt(getBitWidth(), RHS));
878 }
879
872880 /// Regards both *this and RHS as signed quantities and compares them for
873881 /// validity of the less-than relationship.
874882 /// @returns true if *this < RHS when both are considered signed.
875883 /// @brief Signed less than comparison
876884 bool slt(const APInt& RHS) const;
885
886 /// Regards both *this as a signed quantity and compares it with RHS for
887 /// the validity of the less-than relationship.
888 /// @returns true if *this < RHS when considered signed.
889 /// @brief Signed less than comparison
890 bool slt(uint64_t RHS) const {
891 return slt(APInt(getBitWidth(), RHS));
892 }
877893
878894 /// Regards both *this and RHS as unsigned quantities and compares them for
879895 /// validity of the less-or-equal relationship.
883899 return ult(RHS) || eq(RHS);
884900 }
885901
902 /// Regards both *this as an unsigned quantity and compares it with RHS for
903 /// the validity of the less-or-equal relationship.
904 /// @returns true if *this <= RHS when considered unsigned.
905 /// @brief Unsigned less or equal comparison
906 bool ule(uint64_t RHS) const {
907 return ule(APInt(getBitWidth(), RHS));
908 }
909
886910 /// Regards both *this and RHS as signed quantities and compares them for
887911 /// validity of the less-or-equal relationship.
888912 /// @returns true if *this <= RHS when both are considered signed.
891915 return slt(RHS) || eq(RHS);
892916 }
893917
918 /// Regards both *this as a signed quantity and compares it with RHS for
919 /// the validity of the less-or-equal relationship.
920 /// @returns true if *this <= RHS when considered signed.
921 /// @brief Signed less or equal comparison
922 bool sle(uint64_t RHS) const {
923 return sle(APInt(getBitWidth(), RHS));
924 }
925
894926 /// Regards both *this and RHS as unsigned quantities and compares them for
895927 /// the validity of the greater-than relationship.
896928 /// @returns true if *this > RHS when both are considered unsigned.
899931 return !ult(RHS) && !eq(RHS);
900932 }
901933
934 /// Regards both *this as an unsigned quantity and compares it with RHS for
935 /// the validity of the greater-than relationship.
936 /// @returns true if *this > RHS when considered unsigned.
937 /// @brief Unsigned greater than comparison
938 bool ugt(uint64_t RHS) const {
939 return ugt(APInt(getBitWidth(), RHS));
940 }
941
902942 /// Regards both *this and RHS as signed quantities and compares them for
903943 /// the validity of the greater-than relationship.
904944 /// @returns true if *this > RHS when both are considered signed.
907947 return !slt(RHS) && !eq(RHS);
908948 }
909949
950 /// Regards both *this as a signed quantity and compares it with RHS for
951 /// the validity of the greater-than relationship.
952 /// @returns true if *this > RHS when considered signed.
953 /// @brief Signed greater than comparison
954 bool sgt(uint64_t RHS) const {
955 return sgt(APInt(getBitWidth(), RHS));
956 }
957
910958 /// Regards both *this and RHS as unsigned quantities and compares them for
911959 /// validity of the greater-or-equal relationship.
912960 /// @returns true if *this >= RHS when both are considered unsigned.
915963 return !ult(RHS);
916964 }
917965
966 /// Regards both *this as an unsigned quantity and compares it with RHS for
967 /// the validity of the greater-or-equal relationship.
968 /// @returns true if *this >= RHS when considered unsigned.
969 /// @brief Unsigned greater or equal comparison
970 bool uge(uint64_t RHS) const {
971 return uge(APInt(getBitWidth(), RHS));
972 }
973
918974 /// Regards both *this and RHS as signed quantities and compares them for
919975 /// validity of the greater-or-equal relationship.
920976 /// @returns true if *this >= RHS when both are considered signed.
921977 /// @brief Signed greather or equal comparison
922978 bool sge(const APInt& RHS) const {
923979 return !slt(RHS);
980 }
981
982 /// Regards both *this as a signed quantity and compares it with RHS for
983 /// the validity of the greater-or-equal relationship.
984 /// @returns true if *this >= RHS when considered signed.
985 /// @brief Signed greater or equal comparison
986 bool sge(uint64_t RHS) const {
987 return sge(APInt(getBitWidth(), RHS));
924988 }
925989
926990 /// This operation tests if there are any pairs of corresponding bits
40644064 if (I != ConstantEvolutionLoopExitValue.end())
40654065 return I->second;
40664066
4067 if (BEs.ugt(APInt(BEs.getBitWidth(),MaxBruteForceIterations)))
4067 if (BEs.ugt(MaxBruteForceIterations))
40684068 return ConstantEvolutionLoopExitValue[PN] = 0; // Not going to evaluate it.
40694069
40704070 Constant *&RetVal = ConstantEvolutionLoopExitValue[PN];
16131613 I!=E; ++I)
16141614 TSize += I->size();
16151615
1616 if (!areJTsAllowed(TLI) || TSize.ult(APInt(First.getBitWidth(), 4)))
1616 if (!areJTsAllowed(TLI) || TSize.ult(4))
16171617 return false;
16181618
16191619 APInt Range = ComputeRange(First, Last);
18671867 << "Low bound: " << minValue << '\n'
18681868 << "High bound: " << maxValue << '\n');
18691869
1870 if (cmpRange.uge(APInt(cmpRange.getBitWidth(), IntPtrBits)) ||
1870 if (cmpRange.uge(IntPtrBits) ||
18711871 (!(Dests.size() == 1 && numCmps >= 3) &&
18721872 !(Dests.size() == 2 && numCmps >= 5) &&
18731873 !(Dests.size() >= 3 && numCmps >= 6)))
18791879 // Optimize the case where all the case values fit in a
18801880 // word without having to subtract minValue. In this case,
18811881 // we can optimize away the subtraction.
1882 if (minValue.isNonNegative() &&
1883 maxValue.slt(APInt(maxValue.getBitWidth(), IntPtrBits))) {
1882 if (minValue.isNonNegative() && maxValue.slt(IntPtrBits)) {
18841883 cmpRange = maxValue;
18851884 } else {
18861885 lowBound = minValue;
13241324 // If we have a signed (X % (2^c)) == 0, turn it into an unsigned one.
13251325 if (RHSV == 0 && isa(BO->getOperand(1)) &&BO->hasOneUse()){
13261326 const APInt &V = cast(BO->getOperand(1))->getValue();
1327 if (V.sgt(APInt(V.getBitWidth(), 1)) && V.isPowerOf2()) {
1327 if (V.sgt(1) && V.isPowerOf2()) {
13281328 Value *NewRem =
13291329 Builder->CreateURem(BO->getOperand(0), BO->getOperand(1),
13301330 BO->getName());
24462446 if (C->getValue()->getValue().isNegative() !=
24472447 (NewF.AM.BaseOffs < 0) &&
24482448 (C->getValue()->getValue().abs() * APInt(BitWidth, F.AM.Scale))
2449 .ule(APInt(BitWidth, NewF.AM.BaseOffs).abs()))
2449 .ule(abs64(NewF.AM.BaseOffs)))
24502450 continue;
24512451
24522452 // OK, looks good.
24742474 if (C->getValue()->getValue().isNegative() !=
24752475 (NewF.AM.BaseOffs < 0) &&
24762476 C->getValue()->getValue().abs()
2477 .ule(APInt(BitWidth, NewF.AM.BaseOffs).abs()))
2477 .ule(abs64(NewF.AM.BaseOffs)))
24782478 goto skip_formula;
24792479
24802480 // Ok, looks good.