From: Steven Bosscher <stevenb.gcc@gmail.com>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: GCC Mailing List <gcc@gcc.gnu.org>,
Richard Guenther <rguenther@suse.de>,
Alan Modra <amodra@gmail.com>
Subject: Re: A case where PHI-OPT pessimizes the code
Date: Mon, 23 Apr 2012 12:50:00 -0000 [thread overview]
Message-ID: <CABu31nO9reOCtUBHTdo4G7zs+Jcry7=9xs=OjD3_TOvGHgJgEA@mail.gmail.com> (raw)
In-Reply-To: <CAFiYyc3ZdJG_F=LeAo5JpUT_S9Ku9wV7db15EP_ZOpapXf1crA@mail.gmail.com>
On Mon, Apr 23, 2012 at 2:27 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> int foo (_Bool b)
> {
> if (b)
> return 1;
> else
> return 0;
> }
Indeed PHI-OPT performs the transformation on this code, too. But the
resulting code on powerpc64 is fine:
[stevenb@gcc1-power7 gcc]$ cat t.c.149t.optimized
;; Function foo (foo, funcdef_no=0, decl_uid=1996, cgraph_uid=0)
foo (_Bool b)
{
int D.2006;
<bb 2>:
D.2006_4 = (int) b_2(D);
return D.2006_4;
}
[stevenb@gcc1-power7 gcc]$ cat t.s
.file "t.c"
.section ".toc","aw"
.section ".text"
.align 2
.p2align 4,,15
.globl foo
.section ".opd","aw"
.align 3
foo:
.quad .L.foo,.TOC.@tocbase,0
.previous
.type foo, @function
.L.foo:
blr
.long 0
.byte 0,0,0,0,0,0,0,0
.size foo,.-.L.foo
.ident "GCC: (GNU) 4.8.0 20120418 (experimental) [trunk
revision 186580]"
[stevenb@gcc1-power7 gcc]$
However, this C test case shows the problem:
[stevenb@gcc1-power7 gcc]$ head -n 24 t.c
#define ONEUL (1UL)
int
foo (long unsigned int a)
{
_Bool b;
long unsigned int cst, csui;
if (a > 27) goto return_zero;
/*cst = 217579583UL;*/
cst = (ONEUL << 0) | (ONEUL << 1) | (ONEUL << 2) | (ONEUL << 3)
| (ONEUL << 4) |
(ONEUL << 5) | (ONEUL << 19) | (ONEUL << 20) | (ONEUL << 21)
| (ONEUL << 22) |
(ONEUL << 23) | (ONEUL << 26) | (ONEUL << 27);
csui = (ONEUL << a);
b = ((csui & cst) != 0);
if (b)
return 1;
else
return 0;
return_zero:
return 0;
}
[stevenb@gcc1-power7 gcc]$ ./cc1 -quiet -O2 -fdump-tree-all t.c
[stevenb@gcc1-power7 gcc]$ cat t.s
.file "t.c"
.section ".toc","aw"
.section ".text"
.align 2
.p2align 4,,15
.globl foo
.section ".opd","aw"
.align 3
foo:
.quad .L.foo,.TOC.@tocbase,0
.previous
.type foo, @function
.L.foo:
cmpldi 7,3,27
bgt 7,.L3
li 10,1
lis 9,0xcf8
sld 3,10,3
ori 9,9,63
and. 10,3,9
mfcr 9
rlwinm 9,9,3,1
xori 3,9,1
blr
.p2align 4,,15
.L3:
.L2:
li 3,0
blr
.long 0
.byte 0,0,0,0,0,0,0,0
.size foo,.-.L.foo
.ident "GCC: (GNU) 4.8.0 20120418 (experimental) [trunk
revision 186580]"
I will file a PR for this later today, maybe after trying on a few
other targets to see if this is a middle-end problem or a target
issue.
Ciao!
Steven
next prev parent reply other threads:[~2012-04-23 12:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-23 12:16 Steven Bosscher
2012-04-23 12:27 ` Richard Guenther
2012-04-23 12:50 ` Steven Bosscher [this message]
2012-04-23 14:43 ` Alan Modra
2012-04-23 16:08 ` Steven Bosscher
2012-04-24 0:19 ` Alan Modra
2012-04-23 17:00 ` Steven Bosscher
2012-04-23 15:14 ` Jeff Law
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='CABu31nO9reOCtUBHTdo4G7zs+Jcry7=9xs=OjD3_TOvGHgJgEA@mail.gmail.com' \
--to=stevenb.gcc@gmail.com \
--cc=amodra@gmail.com \
--cc=gcc@gcc.gnu.org \
--cc=rguenther@suse.de \
--cc=richard.guenther@gmail.com \
/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).