diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp --- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -1167,7 +1167,11 @@ const PPCSubtarget &Subtarget = CurDAG->getMachineFunction().getSubtarget(); - if (Subtarget.hasPrefixInstrs()) { + // If we have prefix instructions and the non prefix selection decided that + // it cannot materialize the constant in a single instruction it is worth + // trying to materialize using perfix instructions. If the non prefix + // selection used one instruction we cannot do better. + if (Subtarget.hasPrefixInstrs() && InstCntDirect != 1) { unsigned InstCntDirectP = 0; SDNode *ResultP = selectI64ImmDirectPrefix(CurDAG, dl, Imm, InstCntDirectP); // Use the prefix case in either of two cases: