[PowerPC] Don't commute trivial rlwimi instructions
[oota-llvm.git] / lib / Target / PowerPC / PPCInstrInfo.cpp
index 358beaf5bf6b0d8e754851bfdcb8ab861899922c..70e223d78ada650c9bf626be37dc304dfb895cb9 100644 (file)
@@ -571,6 +571,11 @@ PPCInstrInfo::commuteInstruction(MachineInstr *MI, bool NewMI) const {
   unsigned MB = MI->getOperand(4).getImm();
   unsigned ME = MI->getOperand(5).getImm();
 
+  // We can't commute a trivial mask (there is no way to represent an all-zero
+  // mask).
+  if (MB == 0 && ME == 31)
+    return nullptr;
+
   if (NewMI) {
     // Create a new instruction.
     unsigned Reg0 = ChangeReg0 ? Reg2 : MI->getOperand(0).getReg();
@@ -2001,7 +2006,7 @@ PPCInstrInfo::decomposeMachineOperandsTargetFlags(unsigned TF) const {
 ArrayRef<std::pair<unsigned, const char *>>
 PPCInstrInfo::getSerializableDirectMachineOperandTargetFlags() const {
   using namespace PPCII;
-  static std::pair<unsigned, const char *> TargetFlags[] = {
+  static const std::pair<unsigned, const char *> TargetFlags[] = {
       {MO_LO, "ppc-lo"},
       {MO_HA, "ppc-ha"},
       {MO_TPREL_LO, "ppc-tprel-lo"},
@@ -2016,7 +2021,7 @@ PPCInstrInfo::getSerializableDirectMachineOperandTargetFlags() const {
 ArrayRef<std::pair<unsigned, const char *>>
 PPCInstrInfo::getSerializableBitmaskMachineOperandTargetFlags() const {
   using namespace PPCII;
-  static std::pair<unsigned, const char *> TargetFlags[] = {
+  static const std::pair<unsigned, const char *> TargetFlags[] = {
       {MO_PLT_OR_STUB, "ppc-plt-or-stub"},
       {MO_PIC_FLAG, "ppc-pic"},
       {MO_NLP_FLAG, "ppc-nlp"},