public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed] [PR109137] LRA: Do not repeat inheritance and live range splitting in case of asm error
@ 2023-03-22 17:37 Vladimir Makarov
  2023-03-24  8:54 ` [committed] testsuite: Fix up gcc.target/i386/pr109137.c testcase [PR109137] Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Makarov @ 2023-03-22 17:37 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 144 bytes --]

The following patch solves

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

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


[-- Attachment #2: pr109137.patch --]
[-- Type: text/x-patch, Size: 2292 bytes --]

commit 81d762cbec9685c2f2571da21d48f42c42eff33b
Author: Vladimir N. Makarov <vmakarov@redhat.com>
Date:   Wed Mar 22 12:33:11 2023 -0400

    LRA: Do not repeat inheritance and live range splitting in case of asm error
    
    LRA was trying to do live range splitting again and again as there were
    no enough regs for asm.  This patch solves the problem.
    
            PR target/109137
    
    gcc/ChangeLog:
    
            * lra.cc (lra): Do not repeat inheritance and live range splitting
            when asm error is found.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/i386/pr109137.c: New.

diff --git a/gcc/lra.cc b/gcc/lra.cc
index f7fdd601e71..eb3ee1f8b63 100644
--- a/gcc/lra.cc
+++ b/gcc/lra.cc
@@ -2453,7 +2453,7 @@ lra (FILE *f)
 		  lra_hard_reg_split_p = true;
 		}
 	    }
-	  while (fails_p);
+	  while (fails_p && !lra_asm_error_p);
 	  if (! live_p) {
 	    /* We need the correct reg notes for work of constraint sub-pass.  */
 	    lra_create_live_ranges (true, true);
diff --git a/gcc/testsuite/gcc.target/i386/pr109137.c b/gcc/testsuite/gcc.target/i386/pr109137.c
new file mode 100644
index 00000000000..ffd8e8c574b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr109137.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-m32 -O3 -march=znver1 -fPIC -mfpmath=sse -w" } */
+#include <string.h>
+typedef struct {
+  char bytestream_end;
+} CABACContext;
+int get_cabac___trans_tmp_3, get_cabac_tmp, get_cabac_c,
+    decode_cabac_mb_intra4x4_pred_mode_mode, ff_h264_decode_mb_cabac_h_0,
+    ff_h264_decode_mb_cabac_bit;
+typedef struct {
+  char intra4x4_pred_mode_cache[2];
+} H264SliceContext;
+H264SliceContext ff_h264_decode_mb_cabac_sl;
+void ff_h264_decode_mb_cabac(void) {
+  memset((void*)ff_h264_decode_mb_cabac_h_0, 6, 48);
+  int i;
+  for (;; i++) {
+    __asm__(""/* { dg-error "'asm' operand has impossible constraints" } */
+            : "=&r"(ff_h264_decode_mb_cabac_bit), "=&r"(get_cabac_c),
+              "=&r"(get_cabac_c), "=&q"(get_cabac_tmp)
+            : "r"(get_cabac___trans_tmp_3),
+              "r"(__builtin_offsetof(CABACContext, bytestream_end))
+            : "ecx");
+    ff_h264_decode_mb_cabac_sl.intra4x4_pred_mode_cache[i] =
+        decode_cabac_mb_intra4x4_pred_mode_mode;
+  }
+}
+

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [committed] testsuite: Fix up gcc.target/i386/pr109137.c testcase [PR109137]
  2023-03-22 17:37 [pushed] [PR109137] LRA: Do not repeat inheritance and live range splitting in case of asm error Vladimir Makarov
@ 2023-03-24  8:54 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2023-03-24  8:54 UTC (permalink / raw)
  To: Vladimir Makarov; +Cc: gcc-patches

Hi!
On Wed, Mar 22, 2023 at 01:37:39PM -0400, Vladimir Makarov via Gcc-patches wrote:
>             * gcc.target/i386/pr109137.c: New.

The testcase has a couple of small problems:
1) had -m32 in dg-options, that should never be done, instead the test
   should be guarded on ia32
2) adds -fPIC unconditionally (that should be guarded on fpic effective
   target)
3) using #include <string.h> for a RA test seems unnecessary, __builtin_memset
   handles it without the header

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk
as obvious.

2023-03-24  Jakub Jelinek  <jakub@redhat.com>

	PR target/109137
	* gcc.target/i386/pr109137.c: Remove -m32 from dg-options, instead
	require ia32 effective target.  Only add -fPIC for fpic effective
	target.  Remove #include <string.h>, use __builtin_memset instead of
	memset.

--- gcc/testsuite/gcc.target/i386/pr109137.c.jj	2023-03-23 10:00:58.776093791 +0100
+++ gcc/testsuite/gcc.target/i386/pr109137.c	2023-03-23 19:16:37.858850237 +0100
@@ -1,6 +1,8 @@
-/* { dg-do compile } */
-/* { dg-options "-m32 -O3 -march=znver1 -fPIC -mfpmath=sse -w" } */
-#include <string.h>
+/* PR target/109137 */
+/* { dg-do compile { target ia32 } } */
+/* { dg-options "-O3 -march=znver1 -mfpmath=sse -w" } */
+/* { dg-additional-options "-fPIC" { target fpic } } */
+
 typedef struct {
   char bytestream_end;
 } CABACContext;
@@ -12,7 +14,7 @@ typedef struct {
 } H264SliceContext;
 H264SliceContext ff_h264_decode_mb_cabac_sl;
 void ff_h264_decode_mb_cabac(void) {
-  memset((void*)ff_h264_decode_mb_cabac_h_0, 6, 48);
+  __builtin_memset((void*)ff_h264_decode_mb_cabac_h_0, 6, 48);
   int i;
   for (;; i++) {
     __asm__(""/* { dg-error "'asm' operand has impossible constraints" } */
@@ -25,4 +27,3 @@ void ff_h264_decode_mb_cabac(void) {
         decode_cabac_mb_intra4x4_pred_mode_mode;
   }
 }
-


	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-24  9:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-22 17:37 [pushed] [PR109137] LRA: Do not repeat inheritance and live range splitting in case of asm error Vladimir Makarov
2023-03-24  8:54 ` [committed] testsuite: Fix up gcc.target/i386/pr109137.c testcase [PR109137] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).