Skip to content

Commit 53204ee

Browse files
pleathMikeHolman
authored andcommitted
1 parent 9c4772f commit 53204ee

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

lib/Backend/GlobOpt.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5438,7 +5438,8 @@ GlobOpt::GetPrepassValueTypeForDst(
54385438
IR::Instr *const instr,
54395439
Value *const src1Value,
54405440
Value *const src2Value,
5441-
bool const isValueInfoPrecise) const
5441+
bool const isValueInfoPrecise,
5442+
bool const isSafeToTransferInPrepass) const
54425443
{
54435444
// Values with definite types can be created in the loop prepass only when it is guaranteed that the value type will be the
54445445
// same on any iteration of the loop. The heuristics currently used are:
@@ -5455,13 +5456,13 @@ GlobOpt::GetPrepassValueTypeForDst(
54555456
Assert(IsLoopPrePass());
54565457
Assert(instr);
54575458

5458-
if(!desiredValueType.IsDefinite())
5459-
{
5460-
return desiredValueType;
5461-
}
5462-
54635459
if(!isValueInfoPrecise)
54645460
{
5461+
if(!desiredValueType.IsDefinite())
5462+
{
5463+
return isSafeToTransferInPrepass ? desiredValueType : desiredValueType.SetCanBeTaggedValue(true);
5464+
}
5465+
54655466
// If the desired value type is not precise, the value type of the destination is derived from the value types of the
54665467
// sources. Since the value type of a source sym is not definite, the destination value type also cannot be definite.
54675468
if(desiredValueType.IsInt() && OpCodeAttr::IsInt32(instr->m_opcode))
@@ -5474,6 +5475,7 @@ GlobOpt::GetPrepassValueTypeForDst(
54745475
// The op always produces a number, but not always an int
54755476
return desiredValueType.ToDefiniteAnyNumber();
54765477
}
5478+
// Note: ToLikely() also sets CanBeTaggedValue
54775479
return desiredValueType.ToLikely();
54785480
}
54795481

@@ -5750,7 +5752,7 @@ GlobOpt::ValueNumberTransferDstInPrepass(IR::Instr *const instr, Value *const sr
57505752
bool isSafeToTransferInPrepass = false;
57515753
isValueInfoPrecise = IsPrepassSrcValueInfoPrecise(instr, src1Val, nullptr, &isSafeToTransferInPrepass);
57525754

5753-
const ValueType valueType(GetPrepassValueTypeForDst(src1ValueInfo->Type(), instr, src1Val, nullptr, isValueInfoPrecise));
5755+
const ValueType valueType(GetPrepassValueTypeForDst(src1ValueInfo->Type(), instr, src1Val, nullptr, isValueInfoPrecise, isSafeToTransferInPrepass));
57545756
if(isValueInfoPrecise || isSafeToTransferInPrepass)
57555757
{
57565758
Assert(valueType == src1ValueInfo->Type());

lib/Backend/GlobOpt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ class GlobOpt
561561
bool AreFromSameBytecodeFunc(IR::RegOpnd const* src1, IR::RegOpnd const* dst) const;
562562
Value * ValueNumberDst(IR::Instr **pInstr, Value *src1Val, Value *src2Val);
563563
Value * ValueNumberLdElemDst(IR::Instr **pInstr, Value *srcVal);
564-
ValueType GetPrepassValueTypeForDst(const ValueType desiredValueType, IR::Instr *const instr, Value *const src1Value, Value *const src2Value, bool const isValueInfoPreciseRef = false) const;
564+
ValueType GetPrepassValueTypeForDst(const ValueType desiredValueType, IR::Instr *const instr, Value *const src1Value, Value *const src2Value, bool const isValueInfoPreciseRef = false, bool const isSafeToTransferInPrepass = false) const;
565565
bool IsPrepassSrcValueInfoPrecise(IR::Opnd *const src, Value *const srcValue, bool * canTransferValueNumberToDst = nullptr) const;
566566
bool IsPrepassSrcValueInfoPrecise(IR::Instr *const instr, Value *const src1Value, Value *const src2Value, bool * canTransferValueNumberToDst = nullptr) const;
567567
bool IsSafeToTransferInPrepass(StackSym * const sym, ValueInfo *const srcValueInfo) const;

0 commit comments

Comments
 (0)