View | Details | Return to bug 65779 | Differences between
and this patch

Collapse All | Expand All

(-)gcc/shrink-wrap.c.jj (-4 / +47 lines)
Lines 39-44 along with GCC; see the file COPYING3. Link Here
39
#include "shrink-wrap.h"
39
#include "shrink-wrap.h"
40
#include "regcprop.h"
40
#include "regcprop.h"
41
#include "rtl-iter.h"
41
#include "rtl-iter.h"
42
#include "valtrack.h"
42
43
43
44
44
/* Return true if INSN requires the stack frame to be set up.
45
/* Return true if INSN requires the stack frame to be set up.
Lines 149-155 static bool Link Here
149
move_insn_for_shrink_wrap (basic_block bb, rtx_insn *insn,
150
move_insn_for_shrink_wrap (basic_block bb, rtx_insn *insn,
150
			   const HARD_REG_SET uses,
151
			   const HARD_REG_SET uses,
151
			   const HARD_REG_SET defs,
152
			   const HARD_REG_SET defs,
152
			   bool *split_p)
153
			   bool *split_p,
154
			   struct dead_debug_local *debug)
153
{
155
{
154
  rtx set, src, dest;
156
  rtx set, src, dest;
155
  bitmap live_out, live_in, bb_uses, bb_defs;
157
  bitmap live_out, live_in, bb_uses, bb_defs;
Lines 158-163 move_insn_for_shrink_wrap (basic_block b Link Here
158
  unsigned int end_sregno = FIRST_PSEUDO_REGISTER;
160
  unsigned int end_sregno = FIRST_PSEUDO_REGISTER;
159
  basic_block next_block;
161
  basic_block next_block;
160
  edge live_edge;
162
  edge live_edge;
163
  rtx_insn *dinsn;
164
  df_ref def;
161
165
162
  /* Look for a simple register assignment.  We don't use single_set here
166
  /* Look for a simple register assignment.  We don't use single_set here
163
     because we can't deal with any CLOBBERs, USEs, or REG_UNUSED secondary
167
     because we can't deal with any CLOBBERs, USEs, or REG_UNUSED secondary
Lines 298-303 move_insn_for_shrink_wrap (basic_block b Link Here
298
      *split_p = true;
302
      *split_p = true;
299
    }
303
    }
300
304
305
  if (MAY_HAVE_DEBUG_INSNS)
306
    {
307
      for (dinsn = BB_END (bb); dinsn != insn; dinsn = PREV_INSN (dinsn))
308
	if (DEBUG_INSN_P (dinsn))
309
	  {
310
	    df_ref use;
311
	    FOR_EACH_INSN_USE (use, dinsn)
312
	      if (refers_to_regno_p (dregno, end_dregno,
313
				     DF_REF_REG (use), (rtx *) NULL))
314
		dead_debug_add (debug, use, DF_REF_REGNO (use));
315
	  }
316
    }
317
301
  /* At this point we are committed to moving INSN, but let's try to
318
  /* At this point we are committed to moving INSN, but let's try to
302
     move it as far as we can.  */
319
     move it as far as we can.  */
303
  do
320
  do
Lines 363-368 move_insn_for_shrink_wrap (basic_block b Link Here
363
	  if (!live_edge || EDGE_COUNT (live_edge->dest->preds) > 1)
380
	  if (!live_edge || EDGE_COUNT (live_edge->dest->preds) > 1)
364
	    break;
381
	    break;
365
	  next_block = live_edge->dest;
382
	  next_block = live_edge->dest;
383
	  if (MAY_HAVE_DEBUG_INSNS)
384
	    {
385
	      FOR_BB_INSNS_REVERSE (bb, dinsn)
386
		if (DEBUG_INSN_P (dinsn))
387
		  {
388
		    df_ref use;
389
		    FOR_EACH_INSN_USE (use, dinsn)
390
		      if (refers_to_regno_p (dregno, end_dregno,
391
					     DF_REF_REG (use), (rtx *) NULL))
392
			dead_debug_add (debug, use, DF_REF_REGNO (use));
393
		  }
394
	    }
366
	}
395
	}
367
    }
396
    }
368
  while (next_block);
397
  while (next_block);
Lines 384-389 move_insn_for_shrink_wrap (basic_block b Link Here
384
	SET_REGNO_REG_SET (bb_uses, i);
413
	SET_REGNO_REG_SET (bb_uses, i);
385
    }
414
    }
386
415
416
  /* Insert debug temps for dead REGs used in subsequent debug insns.  */
417
  if (debug->used && !bitmap_empty_p (debug->used))
418
    FOR_EACH_INSN_DEF (def, insn)
419
      dead_debug_insert_temp (debug, DF_REF_REGNO (def), insn,
420
			      DEBUG_TEMP_BEFORE_WITH_VALUE);
421
387
  emit_insn_after (PATTERN (insn), bb_note (bb));
422
  emit_insn_after (PATTERN (insn), bb_note (bb));
388
  delete_insn (insn);
423
  delete_insn (insn);
389
  return true;
424
  return true;
Lines 404-409 prepare_shrink_wrap (basic_block entry_b Link Here
404
  HARD_REG_SET uses, defs;
439
  HARD_REG_SET uses, defs;
405
  df_ref def, use;
440
  df_ref def, use;
406
  bool split_p = false;
441
  bool split_p = false;
442
  unsigned int i;
443
  struct dead_debug_local debug;
407
444
408
  if (JUMP_P (BB_END (entry_block)))
445
  if (JUMP_P (BB_END (entry_block)))
409
    {
446
    {
Lines 414-432 prepare_shrink_wrap (basic_block entry_b Link Here
414
      copyprop_hardreg_forward_bb_without_debug_insn (entry_block);
451
      copyprop_hardreg_forward_bb_without_debug_insn (entry_block);
415
    }
452
    }
416
453
454
  dead_debug_local_init (&debug, NULL, NULL);
417
  CLEAR_HARD_REG_SET (uses);
455
  CLEAR_HARD_REG_SET (uses);
418
  CLEAR_HARD_REG_SET (defs);
456
  CLEAR_HARD_REG_SET (defs);
457
419
  FOR_BB_INSNS_REVERSE_SAFE (entry_block, insn, curr)
458
  FOR_BB_INSNS_REVERSE_SAFE (entry_block, insn, curr)
420
    if (NONDEBUG_INSN_P (insn)
459
    if (NONDEBUG_INSN_P (insn)
421
	&& !move_insn_for_shrink_wrap (entry_block, insn, uses, defs,
460
	&& !move_insn_for_shrink_wrap (entry_block, insn, uses, defs,
422
				       &split_p))
461
				       &split_p, &debug))
423
      {
462
      {
424
	/* Add all defined registers to DEFs.  */
463
	/* Add all defined registers to DEFs.  */
425
	FOR_EACH_INSN_DEF (def, insn)
464
	FOR_EACH_INSN_DEF (def, insn)
426
	  {
465
	  {
427
	    x = DF_REF_REG (def);
466
	    x = DF_REF_REG (def);
428
	    if (REG_P (x) && HARD_REGISTER_P (x))
467
	    if (REG_P (x) && HARD_REGISTER_P (x))
429
	      SET_HARD_REG_BIT (defs, REGNO (x));
468
	      for (i = REGNO (x); i < END_REGNO (x); i++)
469
		SET_HARD_REG_BIT (defs, i);
430
	  }
470
	  }
431
471
432
	/* Add all used registers to USESs.  */
472
	/* Add all used registers to USESs.  */
Lines 434-442 prepare_shrink_wrap (basic_block entry_b Link Here
434
	  {
474
	  {
435
	    x = DF_REF_REG (use);
475
	    x = DF_REF_REG (use);
436
	    if (REG_P (x) && HARD_REGISTER_P (x))
476
	    if (REG_P (x) && HARD_REGISTER_P (x))
437
	      SET_HARD_REG_BIT (uses, REGNO (x));
477
	      for (i = REGNO (x); i < END_REGNO (x); i++)
478
		SET_HARD_REG_BIT (uses, i);
438
	  }
479
	  }
439
      }
480
      }
481
482
  dead_debug_local_finish (&debug, NULL);
440
}
483
}
441
484
442
/* Return whether basic block PRO can get the prologue.  It can not if it
485
/* Return whether basic block PRO can get the prologue.  It can not if it
(-)gcc/testsuite/gcc.dg/pr65779.c.jj (+42 lines)
Line 0 Link Here
1
/* PR debug/65779 */
2
/* { dg-do assemble } */
3
/* { dg-options "-O2 -fcompare-debug" } */
4
5
unsigned long
6
foo (unsigned long x, unsigned char *y, unsigned int z)
7
{
8
  unsigned long a = x & 0xffff;
9
  unsigned long b = (x >> 16) & 0xffff;
10
  int k;
11
  if (y == 0) return 1L;
12
  while (z > 0)
13
    {
14
      k = z < 5552 ? z : 5552;
15
      z -= k;
16
      while (k >= 16)
17
	{
18
          a += *y++; b += a;
19
	  a += *y++; b += a;
20
	  a += *y++; b += a;
21
	  a += *y++; b += a;
22
	  a += *y++; b += a;
23
	  a += *y++; b += a;
24
	  a += *y++; b += a;
25
	  a += *y++; b += a;
26
	  a += *y++; b += a;
27
	  a += *y++; b += a;
28
	  a += *y++; b += a;
29
	  a += *y++; b += a;
30
	  a += *y++; b += a;
31
	  a += *y++; b += a;
32
	  a += *y++; b += a;
33
	  a += *y++; b += a;
34
	  k -= 16;
35
        }
36
      if (k != 0)
37
	do { a += *y++; b += a; } while (--k);
38
      a %= 65521L;
39
      b %= 65521L;
40
    }
41
  return (b << 16) | a;
42
}

Return to bug 65779