diff mbox series

[committed,PR104447] LRA: Do not split non-alloc hard regs

Message ID 28c28594-46f5-ce02-5b23-0c979bbbdad4@redhat.com
State New
Headers show
Series [committed,PR104447] LRA: Do not split non-alloc hard regs | expand

Commit Message

Vladimir Makarov Feb. 17, 2022, 4:54 p.m. UTC
The patch solves the following PR:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104447

The patch was successfully bootstrapped and tested on x86-64.
diff mbox series

Patch

commit db69f666a728ce800a840115829f6b64bc3174d2
Author: Vladimir N. Makarov <vmakarov@redhat.com>
Date:   Thu Feb 17 11:31:50 2022 -0500

    [PR104447] LRA: Do not split non-alloc hard regs.
    
    LRA tried to split non-allocated hard reg for reload pseudos again and
    again until number of assignment passes reaches the limit.  The patch fixes
    this.
    
    gcc/ChangeLog:
    
            PR rtl-optimization/104447
            * lra-constraints.cc (spill_hard_reg_in_range): Initiate ignore
            hard reg set by lra_no_alloc_regs.
    
    gcc/testsuite/ChangeLog:
    
            PR rtl-optimization/104447
            * gcc.target/i386/pr104447.c: New.

diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc
index c700c3f4578..b2c4590153c 100644
--- a/gcc/lra-constraints.cc
+++ b/gcc/lra-constraints.cc
@@ -6008,7 +6008,7 @@  spill_hard_reg_in_range (int regno, enum reg_class rclass, rtx_insn *from, rtx_i
   HARD_REG_SET ignore;
   
   lra_assert (from != NULL && to != NULL);
-  CLEAR_HARD_REG_SET (ignore);
+  ignore = lra_no_alloc_regs;
   EXECUTE_IF_SET_IN_BITMAP (&lra_reg_info[regno].insn_bitmap, 0, uid, bi)
     {
       lra_insn_recog_data_t id = lra_insn_recog_data[uid];
diff --git a/gcc/testsuite/gcc.target/i386/pr104447.c b/gcc/testsuite/gcc.target/i386/pr104447.c
new file mode 100644
index 00000000000..bf11e8696e6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr104447.c
@@ -0,0 +1,14 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -pg" } */
+
+int
+bar (int x)
+{
+  asm goto ("" : : "r" (x), "r" (x + 1), "r" (x + 2), "r" (x + 3), /* { dg-error "operand has impossible constraints" } */
+	    "r" (x + 4), "r" (x + 5), "r" (x + 6), "r" (x + 7),
+	    "r" (x + 8), "r" (x + 9), "r" (x + 10), "r" (x + 11),
+	    "r" (x + 12), "r" (x + 13), "r" (x + 14), "r" (x + 15),
+	    "r" (x + 16) : : lab);
+ lab:
+  return 0;
+}