Skip to content

Commit

Permalink
Fix corner case negation of INT_MIN in constrainIabs
Browse files Browse the repository at this point in the history
Similarly with `LONG_MIN` in `constrainLabs`. This functional issue was
introduced while fixing warnings, and this fix has been separated into a
commit of it's own to explicitly islote it.

For full details see the excellent explanation in the following review:
#6030 (comment)
  • Loading branch information
fjeremic committed Jun 7, 2021
1 parent b96541d commit fd52af9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/optimizer/VPHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6930,7 +6930,7 @@ TR::Node *constrainIabs(OMR::ValuePropagation *vp, TR::Node *node)
if (low == high)
{
int32_t value = low;
if (value < 0)
if (value < 0 && value != static_cast<int32_t>(TR::getMinSigned<TR::Int32>()))
value = -value;

TR::VPConstraint *constraint = TR::VPIntConst::create(vp, value);
Expand Down Expand Up @@ -7007,7 +7007,7 @@ TR::Node *constrainLabs(OMR::ValuePropagation *vp, TR::Node *node)
if (low == high)
{
int64_t value = low;
if (value < 0)
if (value < 0 && value != static_cast<int64_t>(TR::getMinSigned<TR::Int64>()))
value = -value;

TR::VPConstraint *constraint = TR::VPLongConst::create(vp, value);
Expand Down

0 comments on commit fd52af9

Please sign in to comment.