WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
196911
DFG IntegerRangeOptimizationPhase fails to optimize the situation when ArithAdd node's second child is a negative constant.
https://bugs.webkit.org/show_bug.cgi?id=196911
Summary
DFG IntegerRangeOptimizationPhase fails to optimize the situation when ArithA...
jundong.xjd
Reported
2019-04-15 00:28:04 PDT
In DFGIntegerRangeOptimizationPhase, the `executeNode` function fails to correctly deal with ArithAdd node when node's second child is a negative constant. ``` case ArithAdd: { ... int offset = node->child2()->asInt32(); ... if (offset < 0 && offset != std::numeric_limits<int>::min()) { // If we have "add: @value - 1" then we know that @value >= min + 1, i.e. that // @value > min. if (!sumOverflows<int>(std::numeric_limits<int>::min(), offset, -1)) { <-- this line definitely returns false because intMin plus two negative value definitely overflows! setRelationship( Relationship::safeCreate( node->child1().node(), m_zero, Relationship::GreaterThan, std::numeric_limits<int>::min() + offset - 1), 0); } // If we have "add: @value + 1" then we know that @add <= max - 1, i.e. that // @add < max. if (!sumOverflows<int>(std::numeric_limits<int>::max(), -offset, 1)) { <-- intMax plus two positive value definitely overflows! setRelationship( Relationship( node, m_zero, Relationship::LessThan, std::numeric_limits<int>::max() - offset + 1), 0); } } break; } ``` If the offset is negative, we have add: @value - C, then we know @value >= min + C, @value > min + C - 1. C equals -offset, so final expression should be @value > min - offset - 1. If the offset is negative, we have add: @value - C, then we know @add <= max - C, @add < max - C + 1. C equals -offset, so final expression should be @add < max + offset + 1.
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2019-04-15 15:15:43 PDT
<
rdar://problem/49919886
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug