View | Details | Return to bug 45695
Collapse All | Expand All

(-)gcc/combine.c.jj (-17 / +22 lines)
Lines 3509-3544 try_combine (rtx i3, rtx i2, rtx i1, int Link Here
3509
	   && GET_CODE (XVECEXP (newpat, 0, 1)) == SET
3509
	   && GET_CODE (XVECEXP (newpat, 0, 1)) == SET
3510
	   && GET_CODE (SET_DEST (XVECEXP (newpat, 0, 1))) != ZERO_EXTRACT
3510
	   && GET_CODE (SET_DEST (XVECEXP (newpat, 0, 1))) != ZERO_EXTRACT
3511
	   && GET_CODE (SET_DEST (XVECEXP (newpat, 0, 1))) != STRICT_LOW_PART
3511
	   && GET_CODE (SET_DEST (XVECEXP (newpat, 0, 1))) != STRICT_LOW_PART
3512
	   && ! use_crosses_set_p (SET_SRC (XVECEXP (newpat, 0, 1)),
3513
				   DF_INSN_LUID (i2))
3514
	   && ! reg_referenced_p (SET_DEST (XVECEXP (newpat, 0, 1)),
3512
	   && ! reg_referenced_p (SET_DEST (XVECEXP (newpat, 0, 1)),
3515
				  XVECEXP (newpat, 0, 0))
3513
				  XVECEXP (newpat, 0, 0))
3516
	   && ! reg_referenced_p (SET_DEST (XVECEXP (newpat, 0, 0)),
3514
	   && ! reg_referenced_p (SET_DEST (XVECEXP (newpat, 0, 0)),
3517
				  XVECEXP (newpat, 0, 1))
3515
				  XVECEXP (newpat, 0, 1))
3518
	   && ! (contains_muldiv (SET_SRC (XVECEXP (newpat, 0, 0)))
3516
	   && ! (contains_muldiv (SET_SRC (XVECEXP (newpat, 0, 0)))
3519
		 && contains_muldiv (SET_SRC (XVECEXP (newpat, 0, 1))))
3517
		 && contains_muldiv (SET_SRC (XVECEXP (newpat, 0, 1)))))
3520
#ifdef HAVE_cc0
3521
	   /* We cannot split the parallel into two sets if both sets
3522
	      reference cc0.  */
3523
	   && ! (reg_referenced_p (cc0_rtx, XVECEXP (newpat, 0, 0))
3524
		 && reg_referenced_p (cc0_rtx, XVECEXP (newpat, 0, 1)))
3525
#endif
3526
	   )
3527
    {
3518
    {
3528
      /* Normally, it doesn't matter which of the two is done first,
3519
      /* Normally, it doesn't matter which of the two is done first,
3529
	 but it does if one references cc0.  In that case, it has to
3520
	 but the one that references cc0 can't be the second, and
3521
	 one which uses any regs/memory set in between i2 and i3 can't
3530
	 be first.  */
3522
	 be first.  */
3523
      bool pat0_in_i2_ok
3524
	= !use_crosses_set_p (SET_SRC (XVECEXP (newpat, 0, 0)),
3525
			      DF_INSN_LUID (i2));
3526
      bool pat1_in_i2_ok
3527
	= !use_crosses_set_p (SET_SRC (XVECEXP (newpat, 0, 1)),
3528
			      DF_INSN_LUID (i2));
3531
#ifdef HAVE_cc0
3529
#ifdef HAVE_cc0
3532
      if (reg_referenced_p (cc0_rtx, XVECEXP (newpat, 0, 0)))
3530
      if (reg_referenced_p (cc0_rtx, XVECEXP (newpat, 0, 0)))
3531
	pat1_in_i2_ok = false;
3532
      if (reg_referenced_p (cc0_rtx, XVECEXP (newpat, 0, 1)))
3533
	pat0_in_i2_ok = false;
3534
#endif
3535
      if (pat1_in_i2_ok)
3536
	{
3537
	  newi2pat = XVECEXP (newpat, 0, 1);
3538
	  newpat = XVECEXP (newpat, 0, 0);
3539
	}
3540
      else if (pat0_in_i2_ok)
3533
	{
3541
	{
3534
	  newi2pat = XVECEXP (newpat, 0, 0);
3542
	  newi2pat = XVECEXP (newpat, 0, 0);
3535
	  newpat = XVECEXP (newpat, 0, 1);
3543
	  newpat = XVECEXP (newpat, 0, 1);
3536
	}
3544
	}
3537
      else
3545
      else
3538
#endif
3539
	{
3546
	{
3540
	  newi2pat = XVECEXP (newpat, 0, 1);
3547
	  undo_all ();
3541
	  newpat = XVECEXP (newpat, 0, 0);
3548
	  return 0;
3542
	}
3549
	}
3543
3550
3544
      i2_code_number = recog_for_combine (&newi2pat, i2, &new_i2_notes);
3551
      i2_code_number = recog_for_combine (&newi2pat, i2, &new_i2_notes);
Lines 3564-3576 try_combine (rtx i3, rtx i2, rtx i1, int Link Here
3564
		  temp = newpat;
3571
		  temp = newpat;
3565
		  newpat = XVECEXP (newi2pat, 0, 0);
3572
		  newpat = XVECEXP (newi2pat, 0, 0);
3566
		  newi2pat = temp;
3573
		  newi2pat = temp;
3567
#ifdef HAVE_cc0
3574
		  if (!pat0_in_i2_ok || !pat1_in_i2_ok)
3568
		  if (reg_referenced_p (cc0_rtx, newpat))
3569
		    {
3575
		    {
3570
		      undo_all ();
3576
		      undo_all ();
3571
		      return 0;
3577
		      return 0;
3572
		    }
3578
		    }
3573
#endif
3574
3579
3575
		  i2_code_number = recog_for_combine (&newi2pat, i2,
3580
		  i2_code_number = recog_for_combine (&newi2pat, i2,
3576
						      &new_i2_notes);
3581
						      &new_i2_notes);
(-)gcc/testsuite/gcc.c-torture/execute/pr45695.c.jj (+32 lines)
Line 0 Link Here
1
/* PR rtl-optimization/45695 */
2
3
extern void abort (void);
4
5
__attribute__((noinline)) void
6
g (int x)
7
{
8
  asm volatile ("" : "+r" (x));
9
}
10
11
__attribute__((noinline)) int
12
f (int a, int b, int d)
13
{
14
  int r = -1;
15
  b += d;
16
  if (d == a)
17
    r = b - d;
18
  g (b);
19
  return r;
20
}
21
22
int
23
main (void)
24
{
25
  int l;
26
  asm ("" : "=r" (l) : "0" (0));
27
  if (f (l + 0, l + 1, l + 4) != -1)
28
    abort ();
29
  if (f (l + 4, l + 1, l + 4) != 1)
30
    abort ();
31
  return 0;
32
}

Return to bug 45695