https://gcc.gnu.org/g:e90131c387a6842586318830df9dfed351abcb07

commit r17-5586-ge90131c387a6842586318830df9dfed351abcb07
Author: Jeff Law <[email protected]>
Date:   Mon Oct 26 10:40:54 2026 -0600

    [RISC-V] Fix various length problems in RISC-V port
    
    Fixes for more things spotted by LLM review of the RISC-V port.  Strictly
    focused on length computations this time.
    
    For the Zba quiet comparison, we emit a single instruction, yet claimed 
size of
    16 bytes.  Trivially fixed.
    
    The call_internal_cfi and call_value_internal_cfi patterns did not account 
for
    the .p2align in the sequence and would thus report too small a size -- by 2
    bytes.  Similarly for gpr_save.
    
    In stack_protect_test we emit 4 instructions, but only reported 12 bytes of
    instruction data.  16 is the right value.
    
    None of these have caused a problem to date, but no reason not to fix them.
    Regression tested on riscv32-elf and riscv64-elf.  Pushing to the trunk.
    
    Assisted-By: Claude, bug discovery
    
    gcc/
            * config/riscv/riscv.md (call_internal_cfi): Account for .p2align in
            size computation.
            (call_value_internal_cfi, gpr_save): Likewise
            (f<quiet_pattern>_quiet<ANYF:mode><X:mode>4_zfa): Fix size 
computation.
            (stack_protect_test_<mode>): Likewise.

Diff:
---
 gcc/config/riscv/riscv.md | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index 3ab1cba58c43..0284512d72c2 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -3805,7 +3805,7 @@
   "f<quiet_pattern>q.<fmt>\t%0,%1,%2"
   [(set_attr "type" "fcmp")
    (set_attr "mode" "<UNITMODE>")
-   (set (attr "length") (const_int 16))])
+   (set (attr "length") (const_int 4))])
 
 ;; fclass instruction output bitmap
 ;;   0 negative infinity
@@ -4295,7 +4295,7 @@
     return "lpad\t0";
   }
   [(set_attr "type" "call")
-   (set_attr "length" "8,12,12")])
+   (set_attr "length" "10,14,14")])
 
 (define_expand "call_value"
   [(parallel [(set (match_operand 0 "")
@@ -4356,7 +4356,7 @@
     return "lpad\t0";
   }
   [(set_attr "type" "call")
-   (set_attr "length" "8,12,12")])
+   (set_attr "length" "10,14,14")])
 
 ;; Call subroutine returning any type.
 
@@ -4418,7 +4418,7 @@
   }
   [(set_attr "type" "call")
    (set (attr "length") (if_then_else (match_test "is_zicfilp_p ()")
-                                     (const_string "12")
+                                     (const_string "14")
                                      (const_string "8")))])
 
 (define_insn "gpr_restore"
@@ -4714,7 +4714,7 @@
     return "xor\t%0, %3, %0\;li\t%3, 0";
   }
   [(set_attr "type" "multi")
-   (set_attr "length" "12")])
+   (set_attr "length" "16")])
 
 (define_insn "riscv_clean_<mode>"
   [(unspec_volatile:X [(match_operand:X 0 "register_operand" "r")]

Reply via email to