public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/40052] New: missed optimizations on logical types: (x | 1) --> 1
@ 2009-05-06 23:02 matz at gcc dot gnu dot org
2009-05-07 8:58 ` [Bug tree-optimization/40052] missed optimizations on (extended) " rguenth at gcc dot gnu dot org
2009-05-07 9:36 ` rguenth at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: matz at gcc dot gnu dot org @ 2009-05-06 23:02 UTC (permalink / raw)
To: gcc-bugs
The testcase from PR40021:
http://gcc.gnu.org/bugzilla/attachment.cgi?id=17800&action=view
shows a current problem in optimizing away logical operations on logical
(boolean) types, like "x | 1" --> "1". This folding is done in some contexts,
and not in others. In particular the testcase
(with -m32 -O2 -ftree-vectorize -msse2 -mfpmath=sse -ffast-math )
leaves this until expand (it's generated quite early already, so there
are multiple possibilities to fold it):
D.1650_109 = D.1648_107 | 1;
if (D.1650_109 != 0)
goto <bb 6>;
else
goto <bb 5>;
Richi already fiddled a bit with this, so CCing him.
--
Summary: missed optimizations on logical types: (x | 1) --> 1
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: matz at gcc dot gnu dot org
GCC host triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40052
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/40052] missed optimizations on (extended) logical types: (x | 1) --> 1
2009-05-06 23:02 [Bug tree-optimization/40052] New: missed optimizations on logical types: (x | 1) --> 1 matz at gcc dot gnu dot org
@ 2009-05-07 8:58 ` rguenth at gcc dot gnu dot org
2009-05-07 9:36 ` rguenth at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-05-07 8:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2009-05-07 08:58 -------
C testcase:
int foo(_Bool b)
{
return b | 1;
}
int bar(_Bool b)
{
return b & -2;
}
should both be folded to return a constant but instead are never optimized,
not even at RTL level.
Due to C semantics we get
return (int) b | 1;
and
return (int) b & -2;
here.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-05-07 08:58:29
date| |
Summary|missed optimizations on |missed optimizations on
|logical types: (x | 1) --> 1|(extended) logical types: (x
| || 1) --> 1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40052
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/40052] missed optimizations on (extended) logical types: (x | 1) --> 1
2009-05-06 23:02 [Bug tree-optimization/40052] New: missed optimizations on logical types: (x | 1) --> 1 matz at gcc dot gnu dot org
2009-05-07 8:58 ` [Bug tree-optimization/40052] missed optimizations on (extended) " rguenth at gcc dot gnu dot org
@ 2009-05-07 9:36 ` rguenth at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-05-07 9:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2009-05-07 09:36 -------
Of course this only works if logicals are zero-extended.
We manage to fold
int foo(unsigned char b)
{
return b | 0xff;
}
but not
int bar(unsigned char b)
{
return b & (~0 << 8);
}
appearantly because the C FE for the former generates (int) (b | 255)
because of some premature optimization in build_binary_op.
We still do not fold
int foo(unsigned char b)
{
return b | 0xfff;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40052
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-07 9:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-06 23:02 [Bug tree-optimization/40052] New: missed optimizations on logical types: (x | 1) --> 1 matz at gcc dot gnu dot org
2009-05-07 8:58 ` [Bug tree-optimization/40052] missed optimizations on (extended) " rguenth at gcc dot gnu dot org
2009-05-07 9:36 ` rguenth at gcc dot gnu dot org
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).