User account creation filtered due to spam.

View | Details | Raw Unified | Return to bug 3507 | Differences between
and this patch

Collapse All | Expand All

(-)gcc/cse.c (+81 lines)
Lines 3909-3914 record_jump_cond (enum rtx_code code, en Link Here
3909
3909
3910
  merge_equiv_classes (op0_elt, op1_elt);
3910
  merge_equiv_classes (op0_elt, op1_elt);
3911
}
3911
}
3912
3913
struct cse_comparison_use
3914
{
3915
  rtx cc_reg;
3916
  rtx comparison_operator;
3917
};
3918
3919
static int
3920
cse_find_comparison_use_1 (rtx *x, void *data)
3921
{
3922
  struct cse_comparison_use *use = data;
3923
  if (GET_RTX_CLASS (GET_CODE (*x)) == RTX_COMM_COMPARE
3924
      || GET_RTX_CLASS (GET_CODE (*x)) == RTX_COMPARE)
3925
    if (rtx_equal_p (XEXP (*x, 0), use->cc_reg))
3926
      {
3927
	use->comparison_operator = *x;
3928
	return 1;
3929
      }
3930
  return 0;
3931
}
3932
3933
static rtx
3934
cse_find_comparison_use (rtx x, rtx insn)
3935
{
3936
  struct cse_comparison_use cmp_use;
3937
  struct df_ref **defs, *use;
3938
  struct df_link *def_use;
3939
  for (defs = DF_INSN_DEFS (insn);
3940
       *defs && DF_REF_REGNO (*defs) != REGNO (x);
3941
       defs++)
3942
    ;
3943
  def_use = *defs ? DF_REF_CHAIN (*defs) : NULL;
3944
  /* Bail out if there are multiple uses.  */
3945
  if (!def_use || def_use->next)
3946
    return NULL_RTX;
3947
  use = def_use->ref;
3948
  cmp_use.cc_reg = x;
3949
  if (for_each_rtx (&DF_REF_INSN (use), cse_find_comparison_use_1, &cmp_use))
3950
    return cmp_use.comparison_operator;
3951
  return 0;
3952
}
3912
3953
3913
/* CSE processing for one instruction.
3954
/* CSE processing for one instruction.
3914
   First simplify sources and addresses of all assignments
3955
   First simplify sources and addresses of all assignments
Lines 4256-4261 cse_insn (rtx insn, rtx libcall_insn) Link Here
4256
	 simplified result, which may not necessarily be valid.  */
4297
	 simplified result, which may not necessarily be valid.  */
4257
      src_folded = fold_rtx (src, insn);
4298
      src_folded = fold_rtx (src, insn);
4258
4299
4300
      /* If src is a comparison a < b, see if a - b was already computed.  */
4301
      if (GET_CODE (src) == COMPARE)
4302
	{
4303
	  enum machine_mode op_mode = GET_MODE (XEXP (src, 0));
4304
	  rtx minus = gen_rtx_MINUS (op_mode, XEXP (src, 0), XEXP (src, 1));
4305
	  unsigned minus_hash = HASH (minus, op_mode);
4306
	  struct table_elt *minus_elt = lookup (minus, minus_hash, op_mode);
4307
	  rtx cmp = NULL_RTX, op1 = NULL_RTX;
4308
4309
	  /* We found it.  Now we need to find out if the comparison is
4310
	     signed or unsigned.  To do so, find the use of dest.  */
4311
	  if (minus_elt)
4312
	      cmp = cse_find_comparison_use (dest, insn);
4313
	  if (cmp)
4314
	    {
4315
	      switch (GET_CODE (cmp))
4316
		{
4317
		/* Because we found a - b already computed, we can assume it
4318
		   won't overflow, but only if signed overflow is undefined.  */
4319
		case LT: case GE: case LE: case GT: case EQ: case NE:
4320
		  if (!flag_trapv && !flag_wrapv && flag_strict_overflow)
4321
		    op1 = const0_rtx;
4322
		  break;
4323
		/* The unsigned case is clean, but needs changes to the insn
4324
		   which uses the comparison result.  We can't do that.  :-( */
4325
		case LTU: case GEU: case LEU: case GTU:
4326
		default:
4327
		  break;
4328
		}
4329
	    }
4330
	  if (op1)
4331
	    {
4332
	      for (minus_elt = minus_elt->first_same_value;
4333
		   minus_elt; minus_elt = minus_elt->next_same_value)
4334
		if (REG_P (minus_elt->exp))
4335
		  src_folded = gen_rtx_COMPARE (mode, minus_elt->exp, op1);
4336
	    }
4337
	}
4338
4259
#if 0
4339
#if 0
4260
      /* ??? This caused bad code to be generated for the m68k port with -O2.
4340
      /* ??? This caused bad code to be generated for the m68k port with -O2.
4261
	 Suppose src is (CONST_INT -1), and that after truncation src_folded
4341
	 Suppose src is (CONST_INT -1), and that after truncation src_folded
Lines 6145-6150 cse_main (rtx f ATTRIBUTE_UNUSED, int nr Link Here
6145
  int *rc_order = XNEWVEC (int, last_basic_block);
6225
  int *rc_order = XNEWVEC (int, last_basic_block);
6146
  int i, n_blocks;
6226
  int i, n_blocks;
6147
6227
6228
  df_chain_add_problem (DF_DU_CHAIN);
6148
  df_set_flags (DF_LR_RUN_DCE);
6229
  df_set_flags (DF_LR_RUN_DCE);
6149
  df_analyze ();
6230
  df_analyze ();
6150
  df_set_flags (DF_DEFER_INSN_RESCAN);
6231
  df_set_flags (DF_DEFER_INSN_RESCAN);

Return to bug 3507