public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "olegendo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/63986] New: [5 Regression][SH] gcc.target/sh/pr51244-15.c failures
Date: Thu, 20 Nov 2014 03:51:00 -0000	[thread overview]
Message-ID: <bug-63986-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 63986
           Summary: [5 Regression][SH] gcc.target/sh/pr51244-15.c failures
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olegendo at gcc dot gnu.org
            Target: sh

Starting with r217496 the SH specific test cases in gcc.target/sh/pr51244-15.c
are failing.
The reason for this is that, e.g. a function such as

typedef char bool;

int
test_0 (int a, int b, int c, int* d)
{
  bool x = a == 0;
  d[2] = !x;
  return x ? b : c;
}

with -O2 -m4 compiles to:
        tst     r4,r4      <<< test against zero
        mov     #-1,r1
        negc    r1,r1
        tst     r4,r4      <<< redundant test against zero
        bt/s    .L5
        mov.l   r1,@(8,r7)
        mov     r6,r5
.L5:
        rts
        mov     r5,r0



and the expected result is:
        tst     r4,r4      <<< only one test against zero
        movt    r0
        xor     #1,r0
        bt/s    .L4
        mov.l   r0,@(8,r7)
        mov     r6,r5
.L4:
        rts
        mov     r5,r0


Before r217496 there are the following insns before the combine pass that are
used to do the test against zero and store the inverted and non-inverted test
result in a reg:

(insn 11 6 14 2 (set (reg:SI 147 t)
        (eq:SI (reg/v:SI 167 [ a ])
            (const_int 0 [0]))) sh_tmp.cpp:55 17 {cmpeqsi_t}
     (expr_list:REG_DEAD (reg/v:SI 167 [ a ])
        (nil)))
(insn 14 11 15 2 (set (reg:SI 163 [ D.1480 ])
        (zero_extend:SI (subreg:QI (reg:SI 147 t) 0))) sh_tmp.cpp:55 398 {movt}
     (expr_list:REG_DEAD (reg:SI 147 t)
        (nil)))
(insn 15 14 16 2 (set (reg:SI 173)
        (xor:SI (reg:SI 163 [ D.1480 ])
            (const_int 1 [0x1]))) sh_tmp.cpp:56 138 {*xorsi3_compact}
     (nil))
(insn 16 15 17 2 (set (reg:SI 174)
        (zero_extend:SI (subreg:QI (reg:SI 173) 0))) sh_tmp.cpp:56 224
{*zero_extendqisi2_compact}
     (expr_list:REG_DEAD (reg:SI 173)
        (nil)))

combine then uses the following pattern from sh.md:

Trying 14 -> 15:
Successfully matched this instruction:
(parallel [
        (set (reg:SI 173)
            (xor:SI (reg:SI 147 t)
                (const_int 1 [0x1])))
        (set (reg:SI 163 [ D.1480 ])
            (zero_extend:SI (subreg:QI (reg:SI 147 t) 0)))
    ])

which is then split into the appropriate/expected insn sequence.


After r217496 the insns before combine look like:

(insn 11 6 12 2 (set (reg:SI 147 t)
        (eq:SI (reg/v:SI 166 [ a ])
            (const_int 0 [0]))) sh_tmp.cpp:56 17 {cmpeqsi_t}
     (nil))

(insn 13 12 14 2 (parallel [
            (set (reg:SI 171 [ D.1480 ])
                (xor:SI (reg:SI 147 t)
                    (const_int 1 [0x1])))
            (set (reg:SI 147 t)
                (const_int 1 [0x1]))
            (use (reg:SI 172))
        ]) sh_tmp.cpp:56 400 {movrt_negc}
     (expr_list:REG_DEAD (reg:SI 172)
        (expr_list:REG_UNUSED (reg:SI 147 t)
            (nil))))

(insn 15 14 7 2 (set (reg:SI 147 t)
        (eq:SI (reg/v:SI 166 [ a ])
            (const_int 0 [0]))) sh_tmp.cpp:57 17 {cmpeqsi_t}
     (expr_list:REG_DEAD (reg/v:SI 166 [ a ])
        (nil)))

and combine does not try the parallel pattern above.
I've briefly tried working around the issue with some combine bridge patterns,
but without any success.

A possible solution could be adding some extra code to the movrt_negc splitter
which looks at the surrounding insn and splits into a movt-xor sequence if
required.  However, I'd like to wait a bit until other pending combine patches
have been installed.


             reply	other threads:[~2014-11-20  3:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-20  3:51 olegendo at gcc dot gnu.org [this message]
2014-11-20  9:55 ` [Bug tree-optimization/63986] " rguenth at gcc dot gnu.org
2014-11-20  9:57 ` rguenth at gcc dot gnu.org
2014-11-20 11:42 ` ebotcazou at gcc dot gnu.org
2014-11-20 13:13 ` ppalka at gcc dot gnu.org
2014-11-20 13:29 ` rguenther at suse dot de
2014-11-20 18:15 ` olegendo at gcc dot gnu.org
2014-11-21  8:29 ` [Bug target/63986] " rguenth at gcc dot gnu.org
2014-11-22  6:40 ` olegendo at gcc dot gnu.org
2014-11-22 15:07 ` olegendo at gcc dot gnu.org
2014-11-25  6:46 ` olegendo at gcc dot gnu.org
2014-12-01  6:50 ` olegendo at gcc dot gnu.org
2014-12-10 15:32 ` rguenth at gcc dot gnu.org
2014-12-10 20:36 ` olegendo 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-63986-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).