public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Franz.Sirl-kernel@lauterbach.com
To: gcc-gnats@gcc.gnu.org
Cc: kevin.hendricks@sympatico.ca
Subject: optimization/7147: ifcvt.c problem (regression)
Date: Thu, 27 Jun 2002 16:06:00 -0000	[thread overview]
Message-ID: <20020627225516.16958.qmail@sources.redhat.com> (raw)


>Number:         7147
>Category:       optimization
>Synopsis:       ifcvt.c problem (regression)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 27 15:56:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Franz.Sirl-kernel@lauterbach.com
>Release:        current gcc-3_1-branch
>Organization:
>Environment:
powerpc-linux-gnu
>Description:
This testcase is derived from a reported c++ mozilla miscompilation. It fails at -O and works fine with -O -fexpensive-optimizations.

My guess so far is that ifcvt.c is confused by the multiple SETs of pseudo 117 (from .rtl):

(insn 27 25 28 (set (reg/v:SI 117)
        (reg:SI 3 r3)) -1 (nil)
    (nil))

(insn 28 27 29 (set (reg:CC 120)
        (compare:CC (reg/v:SI 117)
            (const_int 0 [0x0]))) -1 (nil)
    (nil))

(insn 29 28 31 (set (reg/v:SI 117)
        (eq:SI (reg:CC 120)
            (const_int 0 [0x0]))) -1 (nil)
    (nil))

(jump_insn 31 29 32 (set (pc)
        (label_ref 34)) -1 (nil)
    (nil))

(barrier 32 31 33)

(note 33 32 34 0x30084680 NOTE_INSN_BLOCK_END)

(code_label 34 33 35 3 ("lab1") "" [0 uses])

(note 35 34 37 0x300846c0 NOTE_INSN_BLOCK_END)

(insn 37 35 38 (set (reg:CC 121)
        (compare:CC (reg/v:SI 117)
            (const_int 0 [0x0]))) -1 (nil)
    (nil))

(jump_insn 38 37 40 (set (pc)
        (if_then_else (eq (reg:CC 121)
                (const_int 0 [0x0]))
            (label_ref 48)
            (pc))) -1 (nil)
    (nil))


Somehow the inversion via insn 28 and 29 isn't accounted for.

This is a regression from gcc-2.95.4.
>How-To-Repeat:
Compile with -O on powerpc-linux-gnu:

extern void abort (void);
extern void exit (int);

int sub1 (int val)
{
  return val;
}

int testcond (int val)
{
  int flag1;

    {
      int t1 = val;
        {
          int t2 = t1;
            {
              flag1 = sub1 (t2) ==0;
              goto lab1;
            };
        }
      lab1: ;
    }

  if (flag1 != 0)
    return 0x4d0000;
  else
    return 0;
}

int main (void)
{
  if (testcond (1))
    abort ();
  exit (0);
}

>Fix:
hacking stmt.c like that fixes the bug:

int
preserve_subexpressions_p ()
{
  rtx insn;

  if (flag_expensive_optimizations)
    return 1;

  if (optimize == 0 || cfun == 0 || cfun->stmt == 0 || loop_stack == 0)
    return 0;
+  // make ifcvt happy
+  return 1;
+ 
  insn = get_last_insn_anywhere ();

  return (insn
          && (INSN_UID (insn) - INSN_UID (loop_stack->data.loop.start_label)
              < n_non_fixed_regs * 3));

}
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-06-27 22:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-27 16:06 Franz.Sirl-kernel [this message]
2002-06-30 19:06 Franz Sirl
2002-07-16 14:36 Richard Henderson
2002-07-18  6:06 Franz Sirl
2002-07-18  6:26 Mark Mitchell
2002-09-29  9:42 sayle

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=20020627225516.16958.qmail@sources.redhat.com \
    --to=franz.sirl-kernel@lauterbach.com \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=kevin.hendricks@sympatico.ca \
    /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).