[llvm] 55f91bf - [RISCV] Ignore debug instructions in hasAllNBitUsers in RISCVOptWInstrs.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 3 21:31:43 PST 2023


Author: Craig Topper
Date: 2023-12-03T21:27:50-08:00
New Revision: 55f91bfe5074a22ead581a49e54ec9ed1744b39d

URL: https://github.com/llvm/llvm-project/commit/55f91bfe5074a22ead581a49e54ec9ed1744b39d
DIFF: https://github.com/llvm/llvm-project/commit/55f91bfe5074a22ead581a49e54ec9ed1744b39d.diff

LOG: [RISCV] Ignore debug instructions in hasAllNBitUsers in RISCVOptWInstrs.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVOptWInstrs.cpp
    llvm/test/CodeGen/RISCV/sextw-removal-debug.mir

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVOptWInstrs.cpp b/llvm/lib/Target/RISCV/RISCVOptWInstrs.cpp
index 9101dd67fb0d3..b667a2b7a11ba 100644
--- a/llvm/lib/Target/RISCV/RISCVOptWInstrs.cpp
+++ b/llvm/lib/Target/RISCV/RISCVOptWInstrs.cpp
@@ -128,7 +128,7 @@ static bool hasAllNBitUsers(const MachineInstr &OrigMI,
     if (MI->getNumExplicitDefs() != 1)
       return false;
 
-    for (auto &UserOp : MRI.use_operands(MI->getOperand(0).getReg())) {
+    for (auto &UserOp : MRI.use_nodbg_operands(MI->getOperand(0).getReg())) {
       const MachineInstr *UserMI = UserOp.getParent();
       unsigned OpIdx = UserOp.getOperandNo();
 

diff  --git a/llvm/test/CodeGen/RISCV/sextw-removal-debug.mir b/llvm/test/CodeGen/RISCV/sextw-removal-debug.mir
index c917abbd8f211..f8d6d4b13846e 100644
--- a/llvm/test/CodeGen/RISCV/sextw-removal-debug.mir
+++ b/llvm/test/CodeGen/RISCV/sextw-removal-debug.mir
@@ -47,9 +47,9 @@ body:             |
     ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x12
     ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
     ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr = COPY $x10
-    ; CHECK-NEXT: [[ADDW:%[0-9]+]]:gpr = ADDW [[COPY1]], [[COPY2]], debug-location !11
-    ; CHECK-NEXT: DBG_VALUE [[ADDW]], $noreg, !9, !DIExpression(), debug-location !11
-    ; CHECK-NEXT: SW killed [[ADDW]], [[COPY]], 0, debug-location !12 :: (store (s32) into %ir.c)
+    ; CHECK-NEXT: [[ADD:%[0-9]+]]:gpr = ADD [[COPY1]], [[COPY2]], debug-location !11
+    ; CHECK-NEXT: DBG_VALUE [[ADD]], $noreg, !9, !DIExpression(), debug-location !11
+    ; CHECK-NEXT: SW killed [[ADD]], [[COPY]], 0, debug-location !12 :: (store (s32) into %ir.c)
     ; CHECK-NEXT: PseudoRET debug-location !13
     %2:gpr = COPY $x12
     %1:gpr = COPY $x11


        


More information about the llvm-commits mailing list