Fix problems in the CBE and InstructionCombining which use the isMaxValue
authorReid Spencer <rspencer@reidspencer.com>
Sun, 17 Dec 2006 06:07:30 +0000 (06:07 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Sun, 17 Dec 2006 06:07:30 +0000 (06:07 +0000)
and isMinValue methods of ConstantInt. These have been broken since the
isSigned parameter was added. It is necessary to use the signed version
of the type in the call to isValueValidForType or else incorrect results
are returned.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32637 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Constants.h

index 079f156cca314967f5dc34c2ba8288d703ce0e53..1940e5b831e73bf89e92b6aa31167fa383f6857f 100644 (file)
@@ -205,7 +205,7 @@ public:
       int64_t V = getSExtValue();
       if (V < 0) return false;    // Be careful about wrap-around on 'long's
       ++V;
-      return !isValueValidForType(getType(), V) || V < 0;
+      return !isValueValidForType(getType()->getSignedVersion(), V) || V < 0;
     }
     return isAllOnesValue();
   }
@@ -219,7 +219,7 @@ public:
       int64_t V = getSExtValue();
       if (V > 0) return false;    // Be careful about wrap-around on 'long's
       --V;
-      return !isValueValidForType(getType(), V) || V > 0;
+      return !isValueValidForType(getType()->getSignedVersion(), V) || V > 0;
     }
     return getZExtValue() == 0;
   }