mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1147353 - Odin: simplify the masked index bounds check test. r=sfink, r=luke
This commit is contained in:
parent
e315209812
commit
32c1fe7bea
@ -4443,20 +4443,13 @@ FoldMaskedArrayIndex(FunctionCompiler &f, ParseNode **indexExpr, int32_t *mask,
|
||||
|
||||
uint32_t mask2;
|
||||
if (IsLiteralOrConstInt(f, maskNode, &mask2)) {
|
||||
// Flag the access to skip the bounds check if the mask ensures that an 'out of
|
||||
// bounds' access can not occur based on the current heap length constraint.
|
||||
if (mask2 == 0) {
|
||||
// Flag the access to skip the bounds check if the mask ensures that an
|
||||
// 'out of bounds' access can not occur based on the current heap length
|
||||
// constraint. The unsigned maximum of a masked index is the mask
|
||||
// itself, so check that the mask is not negative and compare the mask
|
||||
// to the known minimum heap length.
|
||||
if (int32_t(mask2) >= 0 && mask2 < f.m().minHeapLength())
|
||||
*needsBoundsCheck = NO_BOUNDS_CHECK;
|
||||
} else {
|
||||
uint32_t minHeap = f.m().minHeapLength();
|
||||
uint32_t minHeapZeroes = CountLeadingZeroes32(minHeap - 1);
|
||||
uint32_t maskZeroes = CountLeadingZeroes32(mask2);
|
||||
if ((minHeapZeroes < maskZeroes) ||
|
||||
(IsPowerOfTwo(minHeap) && minHeapZeroes == maskZeroes))
|
||||
{
|
||||
*needsBoundsCheck = NO_BOUNDS_CHECK;
|
||||
}
|
||||
}
|
||||
*mask &= mask2;
|
||||
*indexExpr = indexNode;
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user