@@ -2859,7 +2859,7 @@ GlobOpt::OptTagChecks(IR::Instr *instr)
2859
2859
2860
2860
if (valueType.CanBeTaggedValue() &&
2861
2861
!valueType.HasBeenNumber() &&
2862
- ( this->IsLoopPrePass() || !this->currentBlock->loop ))
2862
+ ! this->IsLoopPrePass())
2863
2863
{
2864
2864
ValueType newValueType = valueType.SetCanBeTaggedValue(false);
2865
2865
@@ -2883,7 +2883,16 @@ GlobOpt::OptTagChecks(IR::Instr *instr)
2883
2883
bailOutInstr->SetSrc1(srcOpnd);
2884
2884
bailOutInstr->GetSrc1()->SetValueType(valueType);
2885
2885
instr->InsertBefore(bailOutInstr);
2886
-
2886
+ if (this->currentBlock->loop)
2887
+ {
2888
+ // Try hoisting the BailOnNotObject instr.
2889
+ // But since this isn't the current instr being optimized, we need to play tricks with
2890
+ // the byteCodeUse fields...
2891
+ TrackByteCodeUsesForInstrAddedInOptInstr(bailOutInstr, [&]()
2892
+ {
2893
+ TryHoistInvariant(bailOutInstr, this->currentBlock, nullptr, value, nullptr, true, false, false, IR::BailOutOnTaggedValue);
2894
+ });
2895
+ }
2887
2896
if (symOpnd)
2888
2897
{
2889
2898
symOpnd->SetPropertyOwnerValueType(newValueType);
@@ -3968,25 +3977,10 @@ GlobOpt::CopyPropReplaceOpnd(IR::Instr * instr, IR::Opnd * opnd, StackSym * copy
3968
3977
// Try hoisting this checkObjType.
3969
3978
// But since this isn't the current instr being optimized, we need to play tricks with
3970
3979
// the byteCodeUse fields...
3971
- BVSparse<JitArenaAllocator> *currentBytecodeUses = this->byteCodeUses;
3972
- PropertySym * currentPropertySymUse = this->propertySymUse;
3973
- PropertySym * tempPropertySymUse = NULL;
3974
- this->byteCodeUses = NULL;
3975
- BVSparse<JitArenaAllocator> *tempByteCodeUse = JitAnew(this->tempAlloc, BVSparse<JitArenaAllocator>, this->tempAlloc);
3976
- #if DBG
3977
- BVSparse<JitArenaAllocator> *currentBytecodeUsesBeforeOpt = this->byteCodeUsesBeforeOpt;
3978
- this->byteCodeUsesBeforeOpt = tempByteCodeUse;
3979
- #endif
3980
- this->propertySymUse = NULL;
3981
- GlobOpt::TrackByteCodeSymUsed(checkObjTypeInstr, tempByteCodeUse, &tempPropertySymUse);
3982
-
3983
- TryHoistInvariant(checkObjTypeInstr, this->currentBlock, NULL, CurrentBlockData()->FindValue(copySym), NULL, true);
3984
-
3985
- this->byteCodeUses = currentBytecodeUses;
3986
- this->propertySymUse = currentPropertySymUse;
3987
- #if DBG
3988
- this->byteCodeUsesBeforeOpt = currentBytecodeUsesBeforeOpt;
3989
- #endif
3980
+ TrackByteCodeUsesForInstrAddedInOptInstr(checkObjTypeInstr, [&]()
3981
+ {
3982
+ TryHoistInvariant(checkObjTypeInstr, this->currentBlock, NULL, CurrentBlockData()->FindValue(copySym), NULL, true);
3983
+ });
3990
3984
}
3991
3985
}
3992
3986
}
@@ -7072,6 +7066,18 @@ GlobOpt::OptConstFoldUnary(
7072
7066
this->ToFloat64Dst(instr, dst->AsRegOpnd(), this->currentBlock);
7073
7067
}
7074
7068
}
7069
+
7070
+ // If this is an induction variable, then treat it the way the prepass would have if it had seen
7071
+ // the assignment and the resulting change to the value number, and mark it as indeterminate.
7072
+ for (Loop * loop = this->currentBlock->loop; loop; loop = loop->parent)
7073
+ {
7074
+ InductionVariable *iv = nullptr;
7075
+ if (loop->inductionVariables && loop->inductionVariables->TryGetReference(dstSym->m_id, &iv))
7076
+ {
7077
+ iv->SetChangeIsIndeterminate();
7078
+ }
7079
+ }
7080
+
7075
7081
return true;
7076
7082
}
7077
7083
@@ -12391,6 +12397,17 @@ GlobOpt::OptConstFoldBinary(
12391
12397
this->ToInt32Dst(instr, dst->AsRegOpnd(), this->currentBlock);
12392
12398
}
12393
12399
12400
+ // If this is an induction variable, then treat it the way the prepass would have if it had seen
12401
+ // the assignment and the resulting change to the value number, and mark it as indeterminate.
12402
+ for (Loop * loop = this->currentBlock->loop; loop; loop = loop->parent)
12403
+ {
12404
+ InductionVariable *iv = nullptr;
12405
+ if (loop->inductionVariables && loop->inductionVariables->TryGetReference(dstSym->m_id, &iv))
12406
+ {
12407
+ iv->SetChangeIsIndeterminate();
12408
+ }
12409
+ }
12410
+
12394
12411
return true;
12395
12412
}
12396
12413
0 commit comments