Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ runDefault("--useConcurrentJIT=0", "--thresholdForOptimizeAfterWarmUp=100", "--thresholdForFTLOptimizeAfterWarmUp=1000")

function foo(a, b) {
var r = 0;
var w = a | 0;
if (w === 0) {
var x = w - 3;
if (b)
r = Math.abs(x);
}
return r;
}
noInline(foo);

for (var i = 0; i < testLoopCount; ++i) {
var result = foo(0, 1);
if (result !== 3)
throw new Error("bad result at i=" + i + ": " + result);
}
15 changes: 8 additions & 7 deletions Source/JavaScriptCore/dfg/DFGIntegerRangeOptimizationPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,8 @@ class IntegerRangeOptimizationPhase : public Phase {

struct RangeBound {
int32_t value;
const Relationship* proof { nullptr };
Node* proofLeft { nullptr };
Node* proofRight { nullptr };
};

std::optional<std::tuple<RangeBound, RangeBound>> NODELETE rangeFor(Node* node)
Expand All @@ -1043,12 +1044,14 @@ class IntegerRangeOptimizationPhase : public Phase {
int32_t candidateMin = relationship.minValueOfLeft();
if (candidateMin > minBound.value) {
minBound.value = candidateMin;
minBound.proof = &relationship;
minBound.proofLeft = relationship.left().node();
minBound.proofRight = relationship.right().node();
}
int32_t candidateMax = relationship.maxValueOfLeft();
if (candidateMax < maxBound.value) {
maxBound.value = candidateMax;
maxBound.proof = &relationship;
maxBound.proofLeft = relationship.left().node();
maxBound.proofRight = relationship.right().node();
}
}
return std::tuple { minBound, maxBound };
Expand All @@ -1071,11 +1074,9 @@ class IntegerRangeOptimizationPhase : public Phase {

void pinRangeBoundProof(const RangeBound& bound)
{
if (!bound.proof)
return;
if (Node* right = bound.proof->right().node(); right && !right->isConstant())
if (Node* right = bound.proofRight; right && !right->isConstant())
right->mergeFlags(NodeMustGenerate);
if (Node* left = bound.proof->left().node(); left && !left->isConstant())
if (Node* left = bound.proofLeft; left && !left->isConstant())
left->mergeFlags(NodeMustGenerate);
}

Expand Down
Loading