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]

[tree-ssa/mainline] fold fix


Hi,
fold retulrns to early when comparing to coponent_ref missing optimization for
example in following testcase derived from testsuite:
typedef __complex__ float cf;
struct x { char c; cf f; } __attribute__ ((__packed__));
extern void f2 (struct x*);
extern void f1 (void);

void
f2 (struct x *y)
{
  if (y->f != 1)
    abort ();
}
There is code decoposing complex a==b into realpart(a)==realpart(b) &&
imagpart(a)==imagpart(b) this does not happen iff a is component_ref and we die
in the testsuite several times when fold_stmt is called for each statement in
gimple chain because we produce nongimple nodes later.

Bootstrapped/regtest i386-linux mainline, i686-pc-linux-gnu on tree-SSA,
testing together with the additional patch to do the folding in process.  OK?
Honza

2003-11-23  Jan Hubicka  <jh@suse.cz>
	* fold-const.c (fold):  Do not return early when optimizing COMPONENT_REF
	and constant.
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.213.2.63
diff -c -3 -p -r1.213.2.63 fold-const.c
*** fold-const.c	14 Nov 2003 16:50:00 -0000	1.213.2.63
--- fold-const.c	23 Nov 2003 14:23:58 -0000
*************** fold (tree expr)
*** 7607,7613 ****
  	  && (optimize || TREE_CODE (arg1) == INTEGER_CST))
  	{
  	  t1 = optimize_bit_field_compare (code, type, arg0, arg1);
! 	  return t1 ? t1 : t;
  	}
  
        /* If this is a comparison of complex values and either or both sides
--- 7607,7614 ----
  	  && (optimize || TREE_CODE (arg1) == INTEGER_CST))
  	{
  	  t1 = optimize_bit_field_compare (code, type, arg0, arg1);
! 	  if (t1)
! 	    return t1;
  	}
  
        /* If this is a comparison of complex values and either or both sides


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