diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/InstCombine/InstructionCombining.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index e9e05ceb65..dc7fe5cf6b 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -758,7 +758,12 @@ Type *InstCombiner::FindElementAtOffset(Type *Ty, int64_t Offset, FirstIdx = Offset/TySize; Offset -= FirstIdx*TySize; - assert(Offset >= 0 && "Offset should never be negative!"); + // Handle hosts where % returns negative instead of values [0..TySize). + if (Offset < 0) { + --FirstIdx; + Offset += TySize; + assert(Offset >= 0); + } assert((uint64_t)Offset < (uint64_t)TySize && "Out of range offset"); } |