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]

[PATCH] Fix fallout from binary search in add_vars_for_offset


It turns out that the exit test is bogus for overlapping subvars that
start before the searched offset.  Which in turn causes 
gcc.target/i386/loop-3.c to fail on i686.  Fixed thus.

Bootstrapped and testing on x86_64-unknown-linux-gnu in progress, I'll
apply this once it succeeded.

Richard.

2007-10-30  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-operands.c (add_vars_for_offset): Fix exit test
	of loop adding SFTs as virtual operands.

	* gcc.c-torture/execute/20071030-1.c: New testcase copied from
	gcc.target/i386/loop-3.c.

Index: tree-ssa-operands.c
===================================================================
*** tree-ssa-operands.c	(revision 129767)
--- tree-ssa-operands.c	(working copy)
*************** add_vars_for_offset (tree var,
*** 1409,1415 ****
  
    for (; VEC_iterate (tree, sv, i, subvar); ++i)
      {
!       if (size <= SFT_OFFSET (subvar) - offset)
  	break;
  
        if (is_def)
--- 1409,1416 ----
  
    for (; VEC_iterate (tree, sv, i, subvar); ++i)
      {
!       if (SFT_OFFSET (subvar) > offset
! 	  && size <= SFT_OFFSET (subvar) - offset)
  	break;
  
        if (is_def)
Index: testsuite/gcc.c-torture/execute/20071030-1.c
===================================================================
*** testsuite/gcc.c-torture/execute/20071030-1.c	(revision 0)
--- testsuite/gcc.c-torture/execute/20071030-1.c	(revision 0)
***************
*** 0 ****
--- 1,79 ----
+ /* PR target/11044 */
+ /* Originator: Tim McGrath <misty-@charter.net> */
+ /* Testcase contributed by Eric Botcazou <ebotcazou@libertysurf.fr> */
+ 
+ /* Testcase copied from gcc.target/i386/loop-3.c */
+ 
+ extern void *memset (void *, int, __SIZE_TYPE__);
+ extern void abort (void);
+ 
+ typedef struct
+ {
+         unsigned char colormod;
+ } entity_state_t;
+ 
+ typedef struct
+ {
+         int num_entities;
+         entity_state_t *entities;
+ } packet_entities_t;
+ 
+ typedef struct
+ {
+         double senttime;
+         float ping_time;
+         packet_entities_t entities;
+ } client_frame_t;
+ 
+ typedef enum
+ {
+         cs_free,
+         cs_server,
+         cs_zombie,
+         cs_connected,
+         cs_spawned
+ } sv_client_state_t;
+ 
+ typedef struct client_s
+ {
+         sv_client_state_t state;
+         int ping;
+         client_frame_t frames[64];
+ } client_t;
+ 
+ int CalcPing (client_t *cl)
+ {
+         float ping;
+         int count, i;
+         register client_frame_t *frame;
+ 
+         if (cl->state == cs_server)
+                 return cl->ping;
+         ping = 0;
+         count = 0;
+         for (frame = cl->frames, i = 0; i < 64; i++, frame++) {
+                 if (frame->ping_time > 0) {
+                         ping += frame->ping_time;
+                         count++;
+                 }
+         }
+         if (!count)
+                 return 9999;
+         ping /= count;
+ 
+         return ping * 1000;
+ }
+ 
+ int main(void)
+ {
+    client_t cl;
+ 
+    memset(&cl, 0, sizeof(cl));
+ 
+    cl.frames[0].ping_time = 1.0f;
+ 
+    if (CalcPing(&cl) != 1000)
+      abort();
+ 
+    return 0;
+ }


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