This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: SRA bit-field optimization
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: "Richard Guenther" <richard dot guenther at gmail dot com>
- Cc: "Roman Zippel" <zippel at linux-m68k dot org>, "Bernd Schmidt" <bernds_cb1 at t-online dot de>, "Diego Novillo" <dnovillo at acm dot org>, "Daniel Berlin" <dberlin at dberlin dot org>, "GCC Patches" <gcc-patches at gcc dot gnu dot org>, "Andrew Pinski" <pinskia at gmail dot com>, "Eric Botcazou" <ebotcazou at adacore dot com>
- Date: Fri, 05 Oct 2007 13:19:39 -0300
- Subject: Re: SRA bit-field optimization
- References: <orfy4czoyq.fsf@oliva.athome.lsd.ic.unicamp.br> <Pine.LNX.4.64.0707030240580.1820@scrub.home> <orsl82szfw.fsf@oliva.athome.lsd.ic.unicamp.br> <or8x817e6t.fsf_-_@free.oliva.athome.lsd.ic.unicamp.br> <orzlz7iis1.fsf@free.oliva.athome.lsd.ic.unicamp.br> <84fc9c000710021015p4276c5d2s70c75e13a2225f30@mail.gmail.com> <84fc9c000710050803l46ca3bdcq97c8124ceeac95ca@mail.gmail.com>
On Oct 5, 2007, "Richard Guenther" <richard.guenther@gmail.com> wrote:
> On 10/2/07, Richard Guenther <richard.guenther@gmail.com> wrote:
>> It seems this was committed now, and causes ncurses build to fail on
>> x86_64:
> Btw, this is PR33655.
Thanks. Here's a patch that fixes the problem, that I've just started
bootstrapping and regtesting on x86_64-linux-gnu. Ok to install if it
passes?
for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR tree-optimization/33655
* tree-sra.c (bitfield_overlaps_p): Handle array and complex
elements.
for gcc/testsuite/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR tree-optimization/33655
* gcc.dg/torture/pr33655.c: New.
Index: gcc/tree-sra.c
===================================================================
--- gcc/tree-sra.c.orig 2007-10-05 12:53:06.000000000 -0300
+++ gcc/tree-sra.c 2007-10-05 12:54:55.000000000 -0300
@@ -2897,6 +2897,11 @@ bitfield_overlaps_p (tree blen, tree bpo
flen = fold_convert (bitsizetype, TREE_OPERAND (fld->element, 1));
fpos = fold_convert (bitsizetype, TREE_OPERAND (fld->element, 2));
}
+ else if (TREE_CODE (fld->element) == INTEGER_CST)
+ {
+ flen = fold_convert (bitsizetype, TYPE_SIZE (fld->type));
+ fpos = size_binop (MULT_EXPR, flen, fld->element);
+ }
else
gcc_unreachable ();
Index: gcc/testsuite/gcc.dg/torture/pr33655.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/gcc.dg/torture/pr33655.c 2007-10-05 12:54:55.000000000 -0300
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+typedef struct {
+ unsigned long attr;
+ int chars[2];
+} cchar_t;
+typedef struct _win_st {
+ cchar_t _bkgrnd;
+} WINDOW;
+void render_char(WINDOW *win, cchar_t ch)
+{
+ if ((ch).chars[0] == L' '
+ && (ch).chars[1] == L'\0')
+ win->_bkgrnd = ch;
+}
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member http://www.fsfla.org/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}