Skip to content

Commit

Permalink
optimize inBounds check to remove implied constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
nunoplopes committed Dec 20, 2024
1 parent 66bb70c commit c769c3b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ir/pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,10 @@ expr Pointer::isInboundsOf(const Pointer &block, const expr &bytes0,
expr Pointer::isInbounds(bool strict) const {
auto offset = getOffsetSizet();
auto size = blockSizeAlignedOffsetT();
return (strict ? offset.ult(size) : offset.ule(size)) && !offset.isNegative();
expr ret = strict ? offset.ult(size) : offset.ule(size);
if (bits_for_offset <= bits_size_t) // implied
ret &= !offset.isNegative();
return ret;
}

expr Pointer::inbounds(bool simplify_ptr) {
Expand Down

0 comments on commit c769c3b

Please sign in to comment.