public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "law at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/111798] New: [14 Regression] Recent change causing testsuite regression and poor code on mcore-elf
Date: Fri, 13 Oct 2023 15:30:29 +0000	[thread overview]
Message-ID: <bug-111798-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 111798
           Summary: [14 Regression] Recent change causing testsuite
                    regression and poor code on mcore-elf
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: law at gcc dot gnu.org
  Target Milestone: ---

This change:

commit 6decda1a35be5764101987c210b5693a0d914e58
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Oct 12 11:34:57 2023 +0200

    tree-optimization/111779 - Handle some BIT_FIELD_REFs in SRA

    The following handles byte-aligned, power-of-two and byte-multiple
    sized BIT_FIELD_REF reads in SRA.  In particular this should cover
    BIT_FIELD_REFs created by optimize_bit_field_compare.

    For gcc.dg/tree-ssa/ssa-dse-26.c we now SRA the BIT_FIELD_REF
    appearing there leading to more DSE, fully eliding the aggregates.

    This results in the same false positive -Wuninitialized as the
    older attempt to remove the folding from optimize_bit_field_compare,
    fixed by initializing part of the aggregate unconditionally.

            PR tree-optimization/111779
    gcc/
            * tree-sra.cc (sra_handled_bf_read_p): New function.
            (build_access_from_expr_1): Handle some BIT_FIELD_REFs.
            (sra_modify_expr): Likewise.
            (make_fancy_name_1): Skip over BIT_FIELD_REF.

    gcc/fortran/
            * trans-expr.cc (gfc_trans_assignment_1): Initialize
            lhs_caf_attr and rhs_caf_attr codimension flag to avoid
            false positive -Wuninitialized.

    gcc/testsuite/
            * gcc.dg/tree-ssa/ssa-dse-26.c: Adjust for more DSE.
            * gcc.dg/vect/vect-pr111779.c: New testcase.

Causes execute/20040709-2.c to fail on mcore-elf at -O2.  It also results in
what appears to be significantly poorer code generation.

Note I haven't managed to get mcore-elf-gdb to work, so debugging is, umm,
painful.  And I wouldn't put a lot of faith in the simulator correctness.

I have simplified the test to this:
extern void abort (void);
extern void exit (int);

unsigned int
myrnd (void)
{
  static unsigned int s = 1388815473;
  s *= 1103515245;
  s += 12345;
  return (s / 65536) % 2048;
}

struct __attribute__((packed)) K
{
  unsigned int k:6, l:1, j:10, i:15;
};

struct K sK;

unsigned int
fn1K (unsigned int x)
{
  struct K y = sK;
  y.k += x;
  return y.k;
}

void
testK (void)
{
  int i;
  unsigned int mask, v, a, r;
  struct K x;
  char *p = (char *) &sK;
  for (i = 0; i < sizeof (sK); ++i)
    *p++ = myrnd ();
  v = myrnd ();
  a = myrnd ();
  sK.k = v;
  x = sK;
  r = fn1K (a);
  if (x.j != sK.j || x.l != sK.l)
    abort ();
}

int
main (void)
{
  testK ();
  exit (0);
}


Which should at least make the poor code gen obvious.  I don't expect to have
time to debug this further anytime in the near future.

             reply	other threads:[~2023-10-13 15:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13 15:30 law at gcc dot gnu.org [this message]
2023-10-16  6:36 ` [Bug tree-optimization/111798] " rguenth at gcc dot gnu.org
2023-10-16  8:29 ` rguenth at gcc dot gnu.org
2024-03-07 21:04 ` law at gcc dot gnu.org
2024-03-09  6:03 ` law at gcc dot gnu.org
2024-03-11  9:49 ` rguenth at gcc dot gnu.org
2024-05-07  7:42 ` [Bug tree-optimization/111798] [14/15 " rguenth at gcc dot gnu.org

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=bug-111798-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).