This is an archive of the discontinued LLVM Phabricator instance.

InstSimplify: The upper bound of X / C was missing a rounding step
ClosedPublic

Authored by majnemer on Jul 14 2014, 12:48 PM.

Details

Summary

When calculating the upper bound of X / -8589934592, we would perform
the following calculation: Floor[INT_MAX / 8589934592]

However, flooring the result would make us wrongly come to the
conclusion that 1073741824 was not in the set of possible values.
Instead, use the ceiling of the result.

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 11401.Jul 14 2014, 12:48 PM
majnemer retitled this revision from to InstSimplify: The upper bound of X / C was missing a rounding step.
majnemer updated this object.
majnemer added a reviewer: nicholas.
majnemer added a subscriber: Unknown Object (MLST).

LGTM

FYI, this testcase should also be canonicalized by instcombine, which makes
sense to add now that instsimplify isn't catch it ;-)

majnemer closed this revision.Jul 14 2014, 12:58 PM
majnemer updated this revision to Diff 11403.

Closed by commit rL212976 (authored by @majnemer).

We already get this with InstCombine:

%cmp = icmp ne i64 %call, -9223372036854775808
ret i1 %cmp