Don't assume something which might be a constant expression is an instruction.
authorEli Friedman <eli.friedman@gmail.com>
Sat, 2 Apr 2011 22:11:56 +0000 (22:11 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sat, 2 Apr 2011 22:11:56 +0000 (22:11 +0000)
Based on PR9429, but no testcase because I can't figure out how to trigger it
anymore given other changes to the relevant code.

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

lib/Analysis/ValueTracking.cpp

index 0f4bfb7b0d95f5511d51dabf353faa541dd170d2..a8117e6e42e3220d689e47609f8565cd788ea622 100644 (file)
@@ -729,9 +729,9 @@ bool llvm::isPowerOfTwo(Value *V, const TargetData *TD, unsigned Depth) {
   // copying a sign bit (sdiv int_min, 2).
   if (match(V, m_LShr(m_Value(), m_Value())) ||
       match(V, m_UDiv(m_Value(), m_Value()))) {
-    BinaryOperator *BO = cast<BinaryOperator>(V);
-    if (BO->isExact())
-      return isPowerOfTwo(BO->getOperand(0), TD, Depth);
+    PossiblyExactOperator *PEO = cast<PossiblyExactOperator>(V);
+    if (PEO->isExact())
+      return isPowerOfTwo(PEO->getOperand(0), TD, Depth);
   }
 
   return false;