Index: include/llvm/Target/Target.td =================================================================== --- include/llvm/Target/Target.td +++ include/llvm/Target/Target.td @@ -815,7 +815,7 @@ let OutOperandList = (outs unknown:$dst); let InOperandList = (ins variable_ops); let AsmString = "PHINODE"; - let hasSideEffects = 1; + let hasSideEffects = 0; } def INLINEASM : Instruction { let OutOperandList = (outs); Index: lib/CodeGen/MachineLICM.cpp =================================================================== --- lib/CodeGen/MachineLICM.cpp +++ lib/CodeGen/MachineLICM.cpp @@ -856,7 +856,7 @@ bool MachineLICM::IsLICMCandidate(MachineInstr &I) { // Check if it's safe to move the instruction. bool DontMoveAcrossStore = true; - if (!I.isSafeToMove(AA, DontMoveAcrossStore)) + if (I.isPHI() || !I.isSafeToMove(AA, DontMoveAcrossStore)) return false; // If it is load then check if it is guaranteed to execute by making sure that Index: lib/CodeGen/MachineSink.cpp =================================================================== --- lib/CodeGen/MachineSink.cpp +++ lib/CodeGen/MachineSink.cpp @@ -754,7 +754,7 @@ return false; // Check if it's safe to move the instruction. - if (!MI.isSafeToMove(AA, SawStore)) + if (MI.isPHI() || !MI.isSafeToMove(AA, SawStore)) return false; // Convergent operations may not be made control-dependent on additional Index: lib/Target/Hexagon/HexagonBitSimplify.cpp =================================================================== --- lib/Target/Hexagon/HexagonBitSimplify.cpp +++ lib/Target/Hexagon/HexagonBitSimplify.cpp @@ -1319,7 +1319,7 @@ if (MI->getOpcode() == TargetOpcode::COPY) continue; - if (MI->hasUnmodeledSideEffects() || MI->isInlineAsm()) + if (MI->isPHI() || MI->hasUnmodeledSideEffects() || MI->isInlineAsm()) continue; unsigned NumD = MI->getDesc().getNumDefs(); if (NumD != 1) @@ -1329,8 +1329,7 @@ if (!BT.has(RD.Reg)) continue; const BitTracker::RegisterCell &DC = BT.lookup(RD.Reg); - auto At = MI->isPHI() ? B.getFirstNonPHI() - : MachineBasicBlock::iterator(MI); + auto At = MachineBasicBlock::iterator(MI); // Find a source operand that is equal to the result. for (auto &Op : MI->uses()) {