[llvm] [AMDGPU] Save and restore SCC using only 32-bit SGPR. (PR #68367)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 10 05:31:44 PDT 2023


================
@@ -5094,6 +5094,39 @@ unsigned SIInstrInfo::getVALUOp(const MachineInstr &MI) const {
       "Unexpected scalar opcode without corresponding vector one!");
 }
 
+bool SIInstrInfo::isSCCDefinedBefore(MachineBasicBlock &MBB,
+                                     MachineBasicBlock::iterator Before) const {
+
+  for (MachineBasicBlock::iterator I = Before, B = MBB.begin(); I != B; --I) {
+    MachineInstr &MI = *I;
+    if (!MI.hasImplicitDef())
----------------
Pierre-vh wrote:

`hasImplicitDef` is implemented like this:
```
  bool hasImplicitDef() const {
    for (const MachineOperand &MO : implicit_operands())
      if (MO.isDef() && MO.isImplicit())
        return true;
    return false;
  }
```
If you iterate `implicit_operands` below already it's not needed 

https://github.com/llvm/llvm-project/pull/68367


More information about the llvm-commits mailing list