[llvm] r354591 - RegBankSelect: Allow targets to introduce control flow for mapping

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 21 07:48:13 PST 2019


Author: arsenm
Date: Thu Feb 21 07:48:13 2019
New Revision: 354591

URL: http://llvm.org/viewvc/llvm-project?rev=354591&view=rev
Log:
RegBankSelect: Allow targets to introduce control flow for mapping

For AMDGPU, if an operand requires an SGPR but is only available as a
VGPR, a loop needs to be introduced to execute the instruction with
each unique combination of values across all lanes. The rest of the
instructions in the block will be moved to a new block following the
loop. Check if the next instruction's parent changed, and update the
iterators and insertion block if this happened.

Tests will be included in a future patch.

Modified:
    llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp

Modified: llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp?rev=354591&r1=354590&r2=354591&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp Thu Feb 21 07:48:13 2019
@@ -692,8 +692,21 @@ bool RegBankSelect::runOnMachineFunction
                            "unable to map instruction", MI);
         return false;
       }
+
+      // It's possible the mapping changed control flow, and moved the following
+      // instruction to a new block, so figure out the new parent.
+      if (MII != End) {
+        MachineBasicBlock *NextInstBB = MII->getParent();
+        if (NextInstBB != MBB) {
+          LLVM_DEBUG(dbgs() << "Instruction mapping changed control flow\n");
+          MBB = NextInstBB;
+          MIRBuilder.setMBB(*MBB);
+          End = MBB->end();
+        }
+      }
     }
   }
+
   OptMode = SaveOptMode;
   return false;
 }




More information about the llvm-commits mailing list