OSDN Git Service

InstCombine: Clean up weird code that talks about a modulus that's long gone.
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 23 Jan 2013 17:16:22 +0000 (17:16 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 23 Jan 2013 17:16:22 +0000 (17:16 +0000)
This does the right thing unless the multiplication overflows, but the old code
didn't handle that case either.

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

lib/Transforms/InstCombine/InstructionCombining.cpp

index dc7fe5c..e9e05ce 100644 (file)
@@ -758,12 +758,7 @@ Type *InstCombiner::FindElementAtOffset(Type *Ty, int64_t Offset,
     FirstIdx = Offset/TySize;
     Offset -= FirstIdx*TySize;
 
-    // Handle hosts where % returns negative instead of values [0..TySize).
-    if (Offset < 0) {
-      --FirstIdx;
-      Offset += TySize;
-      assert(Offset >= 0);
-    }
+    assert(Offset >= 0 && "Offset should never be negative!");
     assert((uint64_t)Offset < (uint64_t)TySize && "Out of range offset");
   }