This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: SRA bit-field optimization


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}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]