@@ -5438,7 +5438,8 @@ GlobOpt::GetPrepassValueTypeForDst(
5438
5438
IR::Instr *const instr,
5439
5439
Value *const src1Value,
5440
5440
Value *const src2Value,
5441
- bool const isValueInfoPrecise) const
5441
+ bool const isValueInfoPrecise,
5442
+ bool const isSafeToTransferInPrepass) const
5442
5443
{
5443
5444
// Values with definite types can be created in the loop prepass only when it is guaranteed that the value type will be the
5444
5445
// same on any iteration of the loop. The heuristics currently used are:
@@ -5455,13 +5456,13 @@ GlobOpt::GetPrepassValueTypeForDst(
5455
5456
Assert(IsLoopPrePass());
5456
5457
Assert(instr);
5457
5458
5458
- if(!desiredValueType.IsDefinite())
5459
- {
5460
- return desiredValueType;
5461
- }
5462
-
5463
5459
if(!isValueInfoPrecise)
5464
5460
{
5461
+ if(!desiredValueType.IsDefinite())
5462
+ {
5463
+ return isSafeToTransferInPrepass ? desiredValueType : desiredValueType.SetCanBeTaggedValue(true);
5464
+ }
5465
+
5465
5466
// If the desired value type is not precise, the value type of the destination is derived from the value types of the
5466
5467
// sources. Since the value type of a source sym is not definite, the destination value type also cannot be definite.
5467
5468
if(desiredValueType.IsInt() && OpCodeAttr::IsInt32(instr->m_opcode))
@@ -5474,6 +5475,7 @@ GlobOpt::GetPrepassValueTypeForDst(
5474
5475
// The op always produces a number, but not always an int
5475
5476
return desiredValueType.ToDefiniteAnyNumber();
5476
5477
}
5478
+ // Note: ToLikely() also sets CanBeTaggedValue
5477
5479
return desiredValueType.ToLikely();
5478
5480
}
5479
5481
@@ -5750,7 +5752,7 @@ GlobOpt::ValueNumberTransferDstInPrepass(IR::Instr *const instr, Value *const sr
5750
5752
bool isSafeToTransferInPrepass = false;
5751
5753
isValueInfoPrecise = IsPrepassSrcValueInfoPrecise(instr, src1Val, nullptr, &isSafeToTransferInPrepass);
5752
5754
5753
- const ValueType valueType(GetPrepassValueTypeForDst(src1ValueInfo->Type(), instr, src1Val, nullptr, isValueInfoPrecise));
5755
+ const ValueType valueType(GetPrepassValueTypeForDst(src1ValueInfo->Type(), instr, src1Val, nullptr, isValueInfoPrecise, isSafeToTransferInPrepass ));
5754
5756
if(isValueInfoPrecise || isSafeToTransferInPrepass)
5755
5757
{
5756
5758
Assert(valueType == src1ValueInfo->Type());
0 commit comments