aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/InstCombine/InstructionCombining.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp
index e9e05ce..dc7fe5c 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");
}