@@ -5162,24 +5162,13 @@ bool Compiler::optVNIsLoopInvariant(ValueNum vn, FlowGraphNaturalLoop* loop, VNS
51625162 return previousRes;
51635163 }
51645164
5165- bool res = true ;
5166- VNFuncApp funcApp;
5165+ bool res = true ;
5166+ VNFuncApp funcApp;
5167+ VNPhiDef phiDef;
5168+ VNMemoryPhiDef memoryPhiDef;
51675169 if (vnStore->GetVNFunc (vn, &funcApp))
51685170 {
5169- if (funcApp.m_func == VNF_PhiDef)
5170- {
5171- // Is the definition within the loop? If so, is not loop-invariant.
5172- unsigned lclNum = funcApp.m_args [0 ];
5173- unsigned ssaNum = funcApp.m_args [1 ];
5174- LclSsaVarDsc* ssaDef = lvaTable[lclNum].GetPerSsaData (ssaNum);
5175- res = !loop->ContainsBlock (ssaDef->GetBlock ());
5176- }
5177- else if (funcApp.m_func == VNF_PhiMemoryDef)
5178- {
5179- BasicBlock* defnBlk = reinterpret_cast <BasicBlock*>(vnStore->ConstantValue <ssize_t >(funcApp.m_args [0 ]));
5180- res = !loop->ContainsBlock (defnBlk);
5181- }
5182- else if (funcApp.m_func == VNF_MemOpaque)
5171+ if (funcApp.m_func == VNF_MemOpaque)
51835172 {
51845173 const unsigned loopIndex = funcApp.m_args [0 ];
51855174
@@ -5239,6 +5228,16 @@ bool Compiler::optVNIsLoopInvariant(ValueNum vn, FlowGraphNaturalLoop* loop, VNS
52395228 }
52405229 }
52415230 }
5231+ else if (vnStore->GetPhiDef (vn, &phiDef))
5232+ {
5233+ // Is the definition within the loop? If so, is not loop-invariant.
5234+ LclSsaVarDsc* ssaDef = lvaTable[phiDef.LclNum ].GetPerSsaData (phiDef.SsaDef );
5235+ res = !loop->ContainsBlock (ssaDef->GetBlock ());
5236+ }
5237+ else if (vnStore->GetMemoryPhiDef (vn, &memoryPhiDef))
5238+ {
5239+ res = !loop->ContainsBlock (memoryPhiDef.Block );
5240+ }
52425241
52435242 loopVnInvariantCache->Set (vn, res);
52445243 return res;
0 commit comments