diff --git a/src/base/SMPBasicBlock.cpp b/src/base/SMPBasicBlock.cpp index 6694e5121f664091a43bbc54af7a6c5eb56fac70..0638b0d0805ef535f512a4015cf4afacada014c5 100644 --- a/src/base/SMPBasicBlock.cpp +++ b/src/base/SMPBasicBlock.cpp @@ -4104,11 +4104,18 @@ void SMPBasicBlock::MarkAllPhiUsesAliased(STARSOpndTypePtr &PhiMemOp) { assert(nullptr != DefBlock); if (DefBlockNum == (size_t) this->GetNumber()) { // Infinite recursion? How can Phi USE be DEFed in the same Phi? - SMP_msg("ERROR: Phi USE is DEFed in same Phi function, block %d, func %s \n", - DefBlockNum, this->GetFunc()->GetFuncName()); - SMP_msg("PhiMemOp: "); - PrintOperand(PhiMemOp); - SMP_msg(" Phi USESSANum: %d\n", PhiUseSSANum); + // Answer: If there are more than 2 Phi USEs, then one is incoming value at + // atop of loop, one is new value created inside the loop, and one is + // from a path through the loop that does not change this variable, which + // is no problem for non-induction variables. See how many Phi USEs we + // have in this function. + if (2 == PhiUseLimit) { + SMP_msg("ERROR: Phi USE is DEFed in same Phi function, block %d, func %s \n", + DefBlockNum, this->GetFunc()->GetFuncName()); + SMP_msg("PhiMemOp: "); + PrintOperand(PhiMemOp); + SMP_msg(" Phi USESSANum: %d\n", PhiUseSSANum); + } } else { DefBlock->MarkAllPhiUsesAliased(PhiMemOp); diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp index fb4c1882321ffc56122a8131842c7f75b168816b..30c2a13ae09e1ab38190dc3100dfdeaad5ad5e9c 100644 --- a/src/base/SMPFunction.cpp +++ b/src/base/SMPFunction.cpp @@ -8566,10 +8566,12 @@ STARSExpression *SMPFunction::CreateSecondaryBIVLimitExpr(const std::size_t &Loo if (nullptr == FirstInsideDefInst) { return nullptr; } - // Limit to multiplier of 1 initially. Generalize later. + // Limit to multiplier of 1 initially. Generalize and search for SCCP constants values later. bool ImmedMultiplier = IVFamily.BasicInductionVar.Multiplier.GetOp()->IsImmedOp(); - if (!ImmedMultiplier || (1 != IVFamily.BasicInductionVar.Multiplier.GetOp()->GetImmedValue())) { - SMP_msg("ERROR: BIV does not have multiplier of value 1.\n"); + STARS_uval_t MultiplierValue = ImmedMultiplier ? IVFamily.BasicInductionVar.Multiplier.GetOp()->GetImmedValue() : 0; + if (!ImmedMultiplier || (1 != MultiplierValue)) { + SMP_msg("ERROR: BIV has multiplier of value %llu in loop %zu for Func starting at %llx\n", + (uint64_t) MultiplierValue, LoopIndex, (uint64_t) this->GetFirstFuncAddr()); return nullptr; } STARSOpndTypePtr StrideOp = IVFamily.BasicInductionVar.Addend.GetOp()->clone(); @@ -8809,7 +8811,7 @@ STARSExpression* SMPFunction::CreateIterationsExpr(std::size_t LoopIndex, const && (BranchOperator != SMP_BELOW) && (BranchOperator != SMP_BELOW_EQUAL) && (BranchOperator != SMP_NOT_EQUAL)); } } - else { // Decrement by one on each iteration + else { // Decrement on each iteration if (this->LoopComparisonExprs[LoopIndex].ExitsLoop) { Undefined = ((BranchOperator != SMP_LESS_THAN) && (BranchOperator != SMP_LESS_EQUAL) && (BranchOperator != SMP_BELOW) && (BranchOperator != SMP_BELOW_EQUAL) && (BranchOperator != SMP_EQUAL)); diff --git a/src/base/SMPInstr.cpp b/src/base/SMPInstr.cpp index bdbcd661728f9959d000b4869ed4a798f83bf4c0..3c65b553cede940310fc874ff844d32663bf76c4 100644 --- a/src/base/SMPInstr.cpp +++ b/src/base/SMPInstr.cpp @@ -4872,7 +4872,7 @@ SMPInstr::SMPInstr(STARS_ea_t addr) : STARS_ID(addr) { this->address = addr; #endif this->StackPtrOffset = 0; - this->STARSInstPtr = global_stars_interface->CreateInst(this->STARS_ID); + this->STARSInstPtr = std::move(global_stars_interface->CreateInst(this->STARS_ID)); #if 0 this->ResetGoodRTL(); this->ResetJumpTarget();