public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [committed] Fix multiple recent sh3/sh3eb regressions
Date: Wed, 16 Nov 2022 18:51:38 -0700	[thread overview]
Message-ID: <dc69d060-9336-a1fd-fd9b-6bc9a024eb57@gmail.com> (raw)

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


So my tester started showing even more regressions on the sh3/sh4 runs 
recently (beyond the one recently reported in BZ triggered by some DCE 
related changes).  Bisection kept showing inconsistent results.  I was 
starting to think memory management error, but valgrind didn't flag 
anything.

After a bit of head-banging I was able to track it down to predicate 
tests called from the SH specific combiner passes.  And once I started 
getting inside the actual code for the predicate function it became 
pretty obvious.  The predicate routines are supposed to return a bool, 
fine and they dutifully set the low bit in %eax properly.

The *caller* was looking at the full register.  Uh-oh.  Naturally we 
became dependent on what happened to be in the upper 31 bits of a 
register.  That's why the bug would come and go so willy-nilly. This was 
ultimately chased down to an incorrect prototype in sh_treg_combine.cc  
for predicates functions defined via define_predicate.

Removing the bogus prototypes and instead including the generated 
tm-preds.h fixes this problem.  I also checked the other ports for 
similar problems (specifically looking for a extern int.*_operand, then 
for each of the hits looking to see if the predicate was defined via 
define_predicate).  No other ports had similar braindamage.

This fixes the most recent regressions in my tester for sh3/sh3eb and I 
strongly suspect sh4.  It does not fix 107704, but I think Richi and I 
both agree that's a visitation order issue and we were just getting 
lucky before.


Committing to the trunk.



Jeff

[-- Attachment #2: P --]
[-- Type: text/plain, Size: 2791 bytes --]

commit e214cab68cb34e77622b91113f7698cf137bbdd6
Author: Jeff Law <jlaw@ventanamicro.com>
Date:   Wed Nov 16 18:47:59 2022 -0700

    Fix multiple recent sh3/sh3eb regressions
    
    So my tester started showing even more regressions on the sh3/sh4 runs
    recently (beyond the one recently reported in BZ triggered by some DCE
    related changes).  Bisection kept showing inconsistent results.  I was
    starting to think memory management error, but valgrind didn't flag anything.
    
    After a bit of head-banging I was able to track it down to predicate
    tests called from the SH specific combiner passes.  And once I started
    getting inside the actual code for the predicate function it became
    pretty obvious.  The predicate routines are supposed to return a bool,
    fine and they dutifully set the low bit in %eax properly.
    
    The *caller* was looking at the full register.  Uh-oh.  Naturally we
    became dependent on what happened to be in the upper 31 bits of a register.
    That's why the bug would come and go so willy-nilly.  This was ultimately
    chased down to an incorrect prototype in sh_treg_combine.cc for predicate
    functions defined via define_predicate.
    
    Removing the bogus prototypes and instead including the generated
    tm-preds.h fixes this problem.  I also checked the other ports for
    similar problems (specifically looking for a extern int.*_operand, then
    for each of the hits looking to see if the predicate was defined via
    define_predicate).  No other ports had similar braindamage.
    
    This fixes the most recent regressions in my tester for sh3/sh3eb
    and I strongly suspect sh4.  It does not fix 107704, but I think
    Richi and I both agree that's a visitation order issue and we were
    just getting lucky before.
    
    gcc/
    
            * config/sh/sh_treg_combine.cc: Include tm-preds.h.
            (t_reg_operand): Remove bogus prototype.
            (negt_reg_operand): Likewise.

diff --git a/gcc/config/sh/sh_treg_combine.cc b/gcc/config/sh/sh_treg_combine.cc
index f6553c04a0d..ab7dc5d4985 100644
--- a/gcc/config/sh/sh_treg_combine.cc
+++ b/gcc/config/sh/sh_treg_combine.cc
@@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cfgrtl.h"
 #include "tree-pass.h"
 #include "expr.h"
+#include "tm-preds.h"
 
 /*
 This pass tries to optimize for example this:
@@ -426,10 +427,6 @@ is_conditional_insn (rtx_insn* i)
   return GET_CODE (p) == SET && GET_CODE (XEXP (p, 1)) == IF_THEN_ELSE;
 }
 
-// FIXME: Remove dependency on SH predicate function somehow.
-extern int t_reg_operand (rtx, machine_mode);
-extern int negt_reg_operand (rtx, machine_mode);
-
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RTL pass class
 

                 reply	other threads:[~2022-11-17  1:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dc69d060-9336-a1fd-fd9b-6bc9a024eb57@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).