AMDGPU/GlobalISel: Set insert point after waterfall loop
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 4 Jan 2020 16:51:50 +0000 (11:51 -0500)
committerMatt Arsenault <arsenm2@gmail.com>
Mon, 13 Jan 2020 17:51:05 +0000 (12:51 -0500)
The current users of the waterfall loop utility functions do not make
use of the restored original insert point. The insertion is either
done, or they set the insert point somewhere else. A future change
will want to insert instructions after the waterfall loop, but
figuring out the point after the loop is more difficult than ensuring
the insert point is there after the loop.

llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp

index da94099..1bb01dc 100644 (file)
@@ -1021,8 +1021,9 @@ bool AMDGPURegisterBankInfo::executeInWaterfallLoop(
     .addDef(ExecReg)
     .addReg(SaveExecReg);
 
-  // Restore the insert point before the original instruction.
-  B.setInsertPt(MBB, MBB.end());
+  // Set the insert point after the original instruction, so any new
+  // instructions will be in the remainder.
+  B.setInsertPt(*RemainderBB, RemainderBB->begin());
 
   return true;
 }