public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] m68k: add missing early clobber in beq0_di, bne0_di patterns
@ 2014-05-31 12:11 Andreas Schwab
  0 siblings, 0 replies; only message in thread
From: Andreas Schwab @ 2014-05-31 12:11 UTC (permalink / raw)
  To: gcc-patches

This is a wrong code bug that appeared in netcdf when compiling with gcc
4.8.  Due to difference in register allocation this doesn't trigger in
4.9 or trunk, but it is obvious that the bug is only dormant.  The issue
is that if the first operand matches "o" it may contain the same
register as operand 2 as part of the address.  Clearly the register
overlap checks only make sense if the first operand matches "d".  So for
an "o" operand we need to mark the scratch register as early clobber.

Bootstrapped on m68k-suse-linux and installed in trunk.

Andreas.

	* config/m68k/m68k.md (beq0_di, bne0_di): Make the "o" constraint
	a separate alternative where the scratch operand 2 is marked as
	early clobber.
---
 gcc/config/m68k/m68k.md | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/gcc/config/m68k/m68k.md b/gcc/config/m68k/m68k.md
index c4ebb0e..9729624 100644
--- a/gcc/config/m68k/m68k.md
+++ b/gcc/config/m68k/m68k.md
@@ -5961,15 +5961,15 @@
 
 (define_insn "beq0_di"
   [(set (pc)
-    (if_then_else (eq (match_operand:DI 0 "general_operand" "d*ao,<>")
+    (if_then_else (eq (match_operand:DI 0 "general_operand" "d*a,o,<>")
             (const_int 0))
-        (label_ref (match_operand 1 "" ","))
+        (label_ref (match_operand 1 "" ",,"))
         (pc)))
-   (clobber (match_scratch:SI 2 "=d,d"))]
+   (clobber (match_scratch:SI 2 "=d,&d,d"))]
   ""
 {
   CC_STATUS_INIT;
-  if (which_alternative == 1)
+  if (which_alternative == 2)
     return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
   if ((cc_prev_status.value1
       && rtx_equal_p (cc_prev_status.value1, operands[0]))
@@ -6006,11 +6006,11 @@
 
 (define_insn "bne0_di"
   [(set (pc)
-    (if_then_else (ne (match_operand:DI 0 "general_operand" "do,*a")
+    (if_then_else (ne (match_operand:DI 0 "general_operand" "d,o,*a")
             (const_int 0))
-        (label_ref (match_operand 1 "" ","))
+        (label_ref (match_operand 1 "" ",,"))
         (pc)))
-   (clobber (match_scratch:SI 2 "=d,X"))]
+   (clobber (match_scratch:SI 2 "=d,&d,X"))]
   ""
 {
   if ((cc_prev_status.value1
-- 
2.0.0

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-05-31 12:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-31 12:11 [PATCH] m68k: add missing early clobber in beq0_di, bne0_di patterns Andreas Schwab

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).