User account creation filtered due to spam.

View | Details | Raw Unified | Return to bug 43494
Collapse All | Expand All

(-)gcc/rtl.h.orig (+11 lines)
Lines 1916-1921 extern int computed_jump_p (const_rtx); Link Here
1916
typedef int (*rtx_function) (rtx *, void *);
1916
typedef int (*rtx_function) (rtx *, void *);
1917
extern int for_each_rtx (rtx *, rtx_function, void *);
1917
extern int for_each_rtx (rtx *, rtx_function, void *);
1918
1918
1919
/* Callback for for_each_inc_dec, to process the autoinc operation OP
1920
   within MEM.  It sets DEST to SRC + SRCOFF, or SRC if SRCOFF is
1921
   NULL.  The callback is passed the same opaque ARG passed to
1922
   for_each_inc_dec.  Return zero to continue looking for other
1923
   autoinc operations, -1 to skip OP's operands, and any other value
1924
   to interrupt the traversal and return that value to the caller of
1925
   for_each_inc_dec.  */
1926
typedef int (*for_each_inc_dec_fn) (rtx mem, rtx op, rtx dest, rtx src,
1927
				    rtx srcoff, void *arg);
1928
extern int for_each_inc_dec (rtx *, for_each_inc_dec_fn, void *arg);
1929
1919
typedef int (*rtx_equal_p_callback_function) (const_rtx *, const_rtx *,
1930
typedef int (*rtx_equal_p_callback_function) (const_rtx *, const_rtx *,
1920
                                              rtx *, rtx *);
1931
                                              rtx *, rtx *);
1921
extern int rtx_equal_p_cb (const_rtx, const_rtx,
1932
extern int rtx_equal_p_cb (const_rtx, const_rtx,
(-)gcc/rtlanal.c.orig (+115 lines)
Lines 2886-2892 for_each_rtx (rtx *x, rtx_function f, vo Link Here
2886
  return for_each_rtx_1 (*x, i, f, data);
2886
  return for_each_rtx_1 (*x, i, f, data);
2887
}
2887
}
2888
2888
2889
2890
2891
/* Data structure that holds the internal state communicated between
2892
   for_each_inc_dec, for_each_inc_dec_find_mem and
2893
   for_each_inc_dec_find_inc_dec.  */
2894
2895
struct for_each_inc_dec_ops {
2896
  /* The function to be called for each autoinc operation found.  */
2897
  for_each_inc_dec_fn fn;
2898
  /* The opaque argument to be passed to it.  */
2899
  void *arg;
2900
  /* The MEM we're visiting, if any.  */
2901
  rtx mem;
2902
};
2903
2904
static int for_each_inc_dec_find_mem (rtx *r, void *d);
2889
2905
2906
/* Add an insn to do the add inside a x if it is a
2907
   PRE/POST-INC/DEC/MODIFY.  D is an structure containing the insn and
2908
   the size of the mode of the MEM that this is inside of.  */
2909
2910
static int
2911
for_each_inc_dec_find_inc_dec (rtx *r, void *d)
2912
{
2913
  rtx x = *r;
2914
  struct for_each_inc_dec_ops *data = (struct for_each_inc_dec_ops *)d;
2915
  int size = GET_MODE_SIZE (GET_MODE (data->mem));
2916
2917
  switch (GET_CODE (x))
2918
    {
2919
    case PRE_INC:
2920
    case POST_INC:
2921
      {
2922
	rtx r1 = XEXP (x, 0);
2923
	rtx c = gen_int_mode (size, GET_MODE (r1));
2924
	return data->fn (data->mem, x, r1, r1, c, data->arg);
2925
      }
2926
2927
    case PRE_DEC:
2928
    case POST_DEC:
2929
      {
2930
	rtx r1 = XEXP (x, 0);
2931
	rtx c = gen_int_mode (-size, GET_MODE (r1));
2932
	return data->fn (data->mem, x, r1, r1, c, data->arg);
2933
      }
2934
2935
    case PRE_MODIFY:
2936
    case POST_MODIFY:
2937
      {
2938
	rtx r1 = XEXP (x, 0);
2939
	rtx add = XEXP (x, 1);
2940
	return data->fn (data->mem, x, r1, add, NULL, data->arg);
2941
      }
2942
2943
    case MEM:
2944
      {
2945
	rtx save = data->mem;
2946
	int ret = for_each_inc_dec_find_mem (r, d);
2947
	data->mem = save;
2948
	return ret;
2949
      }
2950
2951
    default:
2952
      return 0;
2953
    }
2954
}
2955
2956
/* If X is a MEM, check the address to see if it is PRE/POST-INC/DEC/MODIFY
2957
   and generate an add to replace that.  */
2958
2959
static int
2960
for_each_inc_dec_find_mem (rtx *r, void *d)
2961
{
2962
  rtx x = *r;
2963
  if (x != NULL_RTX && MEM_P (x))
2964
    {
2965
      struct for_each_inc_dec_ops *data = (struct for_each_inc_dec_ops *) d;
2966
      int result;
2967
2968
      data->mem = x;
2969
2970
      result = for_each_rtx (&XEXP (x, 0), for_each_inc_dec_find_inc_dec,
2971
			     data);
2972
      if (result)
2973
	return result;
2974
2975
      return -1;
2976
    }
2977
  return 0;
2978
}
2979
2980
/* Traverse *X looking for MEMs, and for autoinc operations within
2981
   them.  For each such autoinc operation found, call FN, passing it
2982
   the innermost enclosing MEM, the operation itself, the RTX modified
2983
   by the operation, two RTXs (the second may be NULL) that, once
2984
   added, represent the value to be held by the modified RTX
2985
   afterwards, and ARG.  FN is to return -1 to skip looking for other
2986
   autoinc operations within the visited operation, 0 to continue the
2987
   traversal, or any other value to have it returned to the caller of
2988
   for_each_inc_dec.  */
2989
2990
int
2991
for_each_inc_dec (rtx *x,
2992
		  for_each_inc_dec_fn fn,
2993
		  void *arg)
2994
{
2995
  struct for_each_inc_dec_ops data;
2996
2997
  data.fn = fn;
2998
  data.arg = arg;
2999
  data.mem = NULL;
3000
3001
  return for_each_rtx (x, for_each_inc_dec_find_mem, &data);
3002
}
3003
3004
2890
/* Searches X for any reference to REGNO, returning the rtx of the
3005
/* Searches X for any reference to REGNO, returning the rtx of the
2891
   reference found if any.  Otherwise, returns NULL_RTX.  */
3006
   reference found if any.  Otherwise, returns NULL_RTX.  */
2892
3007
(-)gcc/dse.c.orig (-72 / +13 lines)
Lines 807-887 free_store_info (insn_info_t insn_info) Link Here
807
}
807
}
808
808
809
809
810
struct insn_size {
811
  int size;
812
  rtx insn;
813
};
814
815
816
/* Add an insn to do the add inside a x if it is a
817
   PRE/POST-INC/DEC/MODIFY.  D is an structure containing the insn and
818
   the size of the mode of the MEM that this is inside of.  */
819
820
static int
810
static int
821
replace_inc_dec (rtx *r, void *d)
811
emit_inc_dec_insn_before (rtx mem ATTRIBUTE_UNUSED,
812
			  rtx op ATTRIBUTE_UNUSED,
813
			  rtx dest, rtx src, rtx srcoff, void *arg)
822
{
814
{
823
  rtx x = *r;
815
  rtx insn = (rtx)arg;
824
  struct insn_size *data = (struct insn_size *)d;
825
  switch (GET_CODE (x))
826
    {
827
    case PRE_INC:
828
    case POST_INC:
829
      {
830
	rtx r1 = XEXP (x, 0);
831
	rtx c = gen_int_mode (data->size, GET_MODE (r1));
832
	emit_insn_before (gen_rtx_SET (VOIDmode, r1,
833
				       gen_rtx_PLUS (GET_MODE (r1), r1, c)),
834
			  data->insn);
835
	return -1;
836
      }
837
838
    case PRE_DEC:
839
    case POST_DEC:
840
      {
841
	rtx r1 = XEXP (x, 0);
842
	rtx c = gen_int_mode (-data->size, GET_MODE (r1));
843
	emit_insn_before (gen_rtx_SET (VOIDmode, r1,
844
				       gen_rtx_PLUS (GET_MODE (r1), r1, c)),
845
			  data->insn);
846
	return -1;
847
      }
848
849
    case PRE_MODIFY:
850
    case POST_MODIFY:
851
      {
852
	/* We can reuse the add because we are about to delete the
853
	   insn that contained it.  */
854
	rtx add = XEXP (x, 0);
855
	rtx r1 = XEXP (add, 0);
856
	emit_insn_before (gen_rtx_SET (VOIDmode, r1, add), data->insn);
857
	return -1;
858
      }
859
816
860
    default:
817
  if (srcoff)
861
      return 0;
818
    src = gen_rtx_PLUS (GET_MODE (src), src, srcoff);
862
    }
863
}
864
819
820
  /* We can reuse all operands without copying, because we are about
821
     to delete the insn that contained it.  */
865
822
866
/* If X is a MEM, check the address to see if it is PRE/POST-INC/DEC/MODIFY
823
  emit_insn_before (gen_rtx_SET (VOIDmode, dest, src), insn);
867
   and generate an add to replace that.  */
868
824
869
static int
825
  return -1;
870
replace_inc_dec_mem (rtx *r, void *d)
871
{
872
  rtx x = *r;
873
  if (x != NULL_RTX && MEM_P (x))
874
    {
875
      struct insn_size data;
876
877
      data.size = GET_MODE_SIZE (GET_MODE (x));
878
      data.insn = (rtx) d;
879
880
      for_each_rtx (&XEXP (x, 0), replace_inc_dec, &data);
881
882
      return -1;
883
    }
884
  return 0;
885
}
826
}
886
827
887
/* Before we delete INSN, make sure that the auto inc/dec, if it is
828
/* Before we delete INSN, make sure that the auto inc/dec, if it is
Lines 892-898 check_for_inc_dec (rtx insn) Link Here
892
{
833
{
893
  rtx note = find_reg_note (insn, REG_INC, NULL_RTX);
834
  rtx note = find_reg_note (insn, REG_INC, NULL_RTX);
894
  if (note)
835
  if (note)
895
    for_each_rtx (&insn, replace_inc_dec_mem, insn);
836
    for_each_inc_dec (&insn, emit_inc_dec_insn_before, insn);
896
}
837
}
897
838
898
839
Lines 1107-1113 canon_address (rtx mem, Link Here
1107
1048
1108
  *alias_set_out = 0;
1049
  *alias_set_out = 0;
1109
1050
1110
  cselib_lookup (mem_address, address_mode, 1);
1051
  cselib_lookup (mem_address, address_mode, 1, GET_MODE (mem));
1111
1052
1112
  if (dump_file)
1053
  if (dump_file)
1113
    {
1054
    {
Lines 1187-1193 canon_address (rtx mem, Link Here
1187
	}
1128
	}
1188
    }
1129
    }
1189
1130
1190
  *base = cselib_lookup (address, address_mode, true);
1131
  *base = cselib_lookup (address, address_mode, true, GET_MODE (mem));
1191
  *group_id = -1;
1132
  *group_id = -1;
1192
1133
1193
  if (*base == NULL)
1134
  if (*base == NULL)
(-)gcc/cselib.h.orig (-3 / +5 lines)
Lines 70-77 extern void (*cselib_discard_hook) (csel Link Here
70
extern void (*cselib_record_sets_hook) (rtx insn, struct cselib_set *sets,
70
extern void (*cselib_record_sets_hook) (rtx insn, struct cselib_set *sets,
71
					int n_sets);
71
					int n_sets);
72
72
73
extern cselib_val *cselib_lookup (rtx, enum machine_mode, int);
73
extern cselib_val *cselib_lookup (rtx, enum machine_mode,
74
extern cselib_val *cselib_lookup_from_insn (rtx, enum machine_mode, int, rtx);
74
				  int, enum machine_mode);
75
extern cselib_val *cselib_lookup_from_insn (rtx, enum machine_mode,
76
					    int, enum machine_mode, rtx);
75
extern void cselib_init (int);
77
extern void cselib_init (int);
76
extern void cselib_clear_table (void);
78
extern void cselib_clear_table (void);
77
extern void cselib_finish (void);
79
extern void cselib_finish (void);
Lines 85-91 extern rtx cselib_expand_value_rtx_cb (r Link Here
85
				       cselib_expand_callback, void *);
87
				       cselib_expand_callback, void *);
86
extern bool cselib_dummy_expand_value_rtx_cb (rtx, bitmap, int,
88
extern bool cselib_dummy_expand_value_rtx_cb (rtx, bitmap, int,
87
					      cselib_expand_callback, void *);
89
					      cselib_expand_callback, void *);
88
extern rtx cselib_subst_to_values (rtx);
90
extern rtx cselib_subst_to_values (rtx, enum machine_mode);
89
extern void cselib_invalidate_rtx (rtx);
91
extern void cselib_invalidate_rtx (rtx);
90
92
91
extern void cselib_reset_table (unsigned int);
93
extern void cselib_reset_table (unsigned int);
(-)gcc/cselib.c.orig (-55 / +219 lines)
Lines 62-68 static void unchain_one_elt_loc_list (st Link Here
62
static int discard_useless_locs (void **, void *);
62
static int discard_useless_locs (void **, void *);
63
static int discard_useless_values (void **, void *);
63
static int discard_useless_values (void **, void *);
64
static void remove_useless_values (void);
64
static void remove_useless_values (void);
65
static unsigned int cselib_hash_rtx (rtx, int);
65
static int rtx_equal_for_cselib_1 (rtx, rtx, enum machine_mode);
66
static unsigned int cselib_hash_rtx (rtx, int, enum machine_mode);
66
static cselib_val *new_cselib_val (unsigned int, enum machine_mode, rtx);
67
static cselib_val *new_cselib_val (unsigned int, enum machine_mode, rtx);
67
static void add_mem_for_addr (cselib_val *, cselib_val *, rtx);
68
static void add_mem_for_addr (cselib_val *, cselib_val *, rtx);
68
static cselib_val *cselib_lookup_mem (rtx, int);
69
static cselib_val *cselib_lookup_mem (rtx, int);
Lines 390-395 cselib_get_next_uid (void) Link Here
390
  return next_uid;
391
  return next_uid;
391
}
392
}
392
393
394
/* See the documentation of cselib_find_slot below.  */
395
static enum machine_mode find_slot_memmode;
396
397
/* Search for X, whose hashcode is HASH, in CSELIB_HASH_TABLE,
398
   INSERTing if requested.  When X is part of the address of a MEM,
399
   MEMMODE should specify the mode of the MEM.  While searching the
400
   table, MEMMODE is held in FIND_SLOT_MEMMODE, so that autoinc RTXs
401
   in X can be resolved.  */
402
403
static void **
404
cselib_find_slot (rtx x, hashval_t hash, enum insert_option insert,
405
		  enum machine_mode memmode)
406
{
407
  void **slot;
408
  find_slot_memmode = memmode;
409
  slot = htab_find_slot_with_hash (cselib_hash_table, x, hash, insert);
410
  find_slot_memmode = VOIDmode;
411
  return slot;
412
}
413
393
/* The equality test for our hash table.  The first argument ENTRY is a table
414
/* The equality test for our hash table.  The first argument ENTRY is a table
394
   element (i.e. a cselib_val), while the second arg X is an rtx.  We know
415
   element (i.e. a cselib_val), while the second arg X is an rtx.  We know
395
   that all callers of htab_find_slot_with_hash will wrap CONST_INTs into a
416
   that all callers of htab_find_slot_with_hash will wrap CONST_INTs into a
Lines 419-425 entry_and_rtx_equal_p (const void *entry Link Here
419
  /* We don't guarantee that distinct rtx's have different hash values,
440
  /* We don't guarantee that distinct rtx's have different hash values,
420
     so we need to do a comparison.  */
441
     so we need to do a comparison.  */
421
  for (l = v->locs; l; l = l->next)
442
  for (l = v->locs; l; l = l->next)
422
    if (rtx_equal_for_cselib_p (l->loc, x))
443
    if (rtx_equal_for_cselib_1 (l->loc, x, find_slot_memmode))
423
      {
444
      {
424
	promote_debug_loc (l);
445
	promote_debug_loc (l);
425
	return 1;
446
	return 1;
Lines 631-643 cselib_reg_set_mode (const_rtx x) Link Here
631
int
652
int
632
rtx_equal_for_cselib_p (rtx x, rtx y)
653
rtx_equal_for_cselib_p (rtx x, rtx y)
633
{
654
{
655
  return rtx_equal_for_cselib_1 (x, y, VOIDmode);
656
}
657
658
/* If x is a PLUS or an autoinc operation, expand the operation,
659
   storing the offset, if any, in *OFF.  */
660
661
static rtx
662
autoinc_split (rtx x, rtx *off, enum machine_mode memmode)
663
{
664
  switch (GET_CODE (x))
665
    {
666
    case PLUS:
667
      *off = XEXP (x, 1);
668
      return XEXP (x, 0);
669
670
    case PRE_DEC:
671
      if (memmode == VOIDmode)
672
	return x;
673
674
      *off = GEN_INT (-GET_MODE_SIZE (memmode));
675
      return XEXP (x, 0);
676
      break;
677
678
    case PRE_INC:
679
      if (memmode == VOIDmode)
680
	return x;
681
682
      *off = GEN_INT (GET_MODE_SIZE (memmode));
683
      return XEXP (x, 0);
684
685
    case PRE_MODIFY:
686
      return XEXP (x, 1);
687
688
    case POST_DEC:
689
    case POST_INC:
690
    case POST_MODIFY:
691
      return XEXP (x, 0);
692
693
    default:
694
      return x;
695
    }
696
}
697
698
static int
699
rtx_equal_for_cselib_1 (rtx x, rtx y, enum machine_mode memmode)
700
{
634
  enum rtx_code code;
701
  enum rtx_code code;
635
  const char *fmt;
702
  const char *fmt;
636
  int i;
703
  int i;
637
704
638
  if (REG_P (x) || MEM_P (x))
705
  if (REG_P (x) || MEM_P (x))
639
    {
706
    {
640
      cselib_val *e = cselib_lookup (x, GET_MODE (x), 0);
707
      cselib_val *e = cselib_lookup (x, GET_MODE (x), 0, memmode);
641
708
642
      if (e)
709
      if (e)
643
	x = e->val_rtx;
710
	x = e->val_rtx;
Lines 645-651 rtx_equal_for_cselib_p (rtx x, rtx y) Link Here
645
712
646
  if (REG_P (y) || MEM_P (y))
713
  if (REG_P (y) || MEM_P (y))
647
    {
714
    {
648
      cselib_val *e = cselib_lookup (y, GET_MODE (y), 0);
715
      cselib_val *e = cselib_lookup (y, GET_MODE (y), 0, memmode);
649
716
650
      if (e)
717
      if (e)
651
	y = e->val_rtx;
718
	y = e->val_rtx;
Lines 669-675 rtx_equal_for_cselib_p (rtx x, rtx y) Link Here
669
	  /* Avoid infinite recursion.  */
736
	  /* Avoid infinite recursion.  */
670
	  if (REG_P (t) || MEM_P (t))
737
	  if (REG_P (t) || MEM_P (t))
671
	    continue;
738
	    continue;
672
	  else if (rtx_equal_for_cselib_p (t, y))
739
	  else if (rtx_equal_for_cselib_1 (t, y, memmode))
673
	    return 1;
740
	    return 1;
674
	}
741
	}
675
742
Lines 687-702 rtx_equal_for_cselib_p (rtx x, rtx y) Link Here
687
754
688
	  if (REG_P (t) || MEM_P (t))
755
	  if (REG_P (t) || MEM_P (t))
689
	    continue;
756
	    continue;
690
	  else if (rtx_equal_for_cselib_p (x, t))
757
	  else if (rtx_equal_for_cselib_1 (x, t, memmode))
691
	    return 1;
758
	    return 1;
692
	}
759
	}
693
760
694
      return 0;
761
      return 0;
695
    }
762
    }
696
763
697
  if (GET_CODE (x) != GET_CODE (y) || GET_MODE (x) != GET_MODE (y))
764
  if (GET_MODE (x) != GET_MODE (y))
698
    return 0;
765
    return 0;
699
766
767
  if (GET_CODE (x) != GET_CODE (y))
768
    {
769
      rtx xorig = x, yorig = y;
770
      rtx xoff = NULL, yoff = NULL;
771
772
      x = autoinc_split (x, &xoff, memmode);
773
      y = autoinc_split (y, &yoff, memmode);
774
775
      if (!xoff != !yoff)
776
	return 0;
777
778
      if (xoff && !rtx_equal_for_cselib_1 (xoff, yoff, memmode))
779
	return 0;
780
781
      /* Don't recurse if nothing changed.  */
782
      if (x != xorig || y != yorig)
783
	return rtx_equal_for_cselib_1 (x, y, memmode);
784
785
      return 0;
786
    }
787
700
  /* These won't be handled correctly by the code below.  */
788
  /* These won't be handled correctly by the code below.  */
701
  switch (GET_CODE (x))
789
  switch (GET_CODE (x))
702
    {
790
    {
Lines 712-717 rtx_equal_for_cselib_p (rtx x, rtx y) Link Here
712
    case LABEL_REF:
800
    case LABEL_REF:
713
      return XEXP (x, 0) == XEXP (y, 0);
801
      return XEXP (x, 0) == XEXP (y, 0);
714
802
803
    case MEM:
804
      /* We have to compare any autoinc operations in the addresses
805
	 using this MEM's mode.  */
806
      return rtx_equal_for_cselib_1 (XEXP (x, 0), XEXP (y, 0), GET_MODE (x));
807
715
    default:
808
    default:
716
      break;
809
      break;
717
    }
810
    }
Lines 744-761 rtx_equal_for_cselib_p (rtx x, rtx y) Link Here
744
837
745
	  /* And the corresponding elements must match.  */
838
	  /* And the corresponding elements must match.  */
746
	  for (j = 0; j < XVECLEN (x, i); j++)
839
	  for (j = 0; j < XVECLEN (x, i); j++)
747
	    if (! rtx_equal_for_cselib_p (XVECEXP (x, i, j),
840
	    if (! rtx_equal_for_cselib_1 (XVECEXP (x, i, j),
748
					  XVECEXP (y, i, j)))
841
					  XVECEXP (y, i, j), memmode))
749
	      return 0;
842
	      return 0;
750
	  break;
843
	  break;
751
844
752
	case 'e':
845
	case 'e':
753
	  if (i == 1
846
	  if (i == 1
754
	      && targetm.commutative_p (x, UNKNOWN)
847
	      && targetm.commutative_p (x, UNKNOWN)
755
	      && rtx_equal_for_cselib_p (XEXP (x, 1), XEXP (y, 0))
848
	      && rtx_equal_for_cselib_1 (XEXP (x, 1), XEXP (y, 0), memmode)
756
	      && rtx_equal_for_cselib_p (XEXP (x, 0), XEXP (y, 1)))
849
	      && rtx_equal_for_cselib_1 (XEXP (x, 0), XEXP (y, 1), memmode))
757
	    return 1;
850
	    return 1;
758
	  if (! rtx_equal_for_cselib_p (XEXP (x, i), XEXP (y, i)))
851
	  if (! rtx_equal_for_cselib_1 (XEXP (x, i), XEXP (y, i), memmode))
759
	    return 0;
852
	    return 0;
760
	  break;
853
	  break;
761
854
Lines 807-812 wrap_constant (enum machine_mode mode, r Link Here
807
   that take commutativity into account.
900
   that take commutativity into account.
808
   If we wanted to also support associative rules, we'd have to use a different
901
   If we wanted to also support associative rules, we'd have to use a different
809
   strategy to avoid returning spurious 0, e.g. return ~(~0U >> 1) .
902
   strategy to avoid returning spurious 0, e.g. return ~(~0U >> 1) .
903
   MEMMODE indicates the mode of an enclosing MEM, and it's only
904
   used to compute auto-inc values.
810
   We used to have a MODE argument for hashing for CONST_INTs, but that
905
   We used to have a MODE argument for hashing for CONST_INTs, but that
811
   didn't make sense, since it caused spurious hash differences between
906
   didn't make sense, since it caused spurious hash differences between
812
    (set (reg:SI 1) (const_int))
907
    (set (reg:SI 1) (const_int))
Lines 817-823 wrap_constant (enum machine_mode mode, r Link Here
817
   in a comparison anyway, since relying on hash differences is unsafe.  */
912
   in a comparison anyway, since relying on hash differences is unsafe.  */
818
913
819
static unsigned int
914
static unsigned int
820
cselib_hash_rtx (rtx x, int create)
915
cselib_hash_rtx (rtx x, int create, enum machine_mode memmode)
821
{
916
{
822
  cselib_val *e;
917
  cselib_val *e;
823
  int i, j;
918
  int i, j;
Lines 832-838 cselib_hash_rtx (rtx x, int create) Link Here
832
    {
927
    {
833
    case MEM:
928
    case MEM:
834
    case REG:
929
    case REG:
835
      e = cselib_lookup (x, GET_MODE (x), create);
930
      e = cselib_lookup (x, GET_MODE (x), create, memmode);
836
      if (! e)
931
      if (! e)
837
	return 0;
932
	return 0;
838
933
Lines 878-884 cselib_hash_rtx (rtx x, int create) Link Here
878
	for (i = 0; i < units; ++i)
973
	for (i = 0; i < units; ++i)
879
	  {
974
	  {
880
	    elt = CONST_VECTOR_ELT (x, i);
975
	    elt = CONST_VECTOR_ELT (x, i);
881
	    hash += cselib_hash_rtx (elt, 0);
976
	    hash += cselib_hash_rtx (elt, 0, memmode);
882
	  }
977
	  }
883
978
884
	return hash;
979
	return hash;
Lines 911-920 cselib_hash_rtx (rtx x, int create) Link Here
911
1006
912
    case PRE_DEC:
1007
    case PRE_DEC:
913
    case PRE_INC:
1008
    case PRE_INC:
1009
      /* We can't compute these without knowing the MEM mode.  */
1010
      gcc_assert (memmode != VOIDmode);
1011
      i = GET_MODE_SIZE (memmode);
1012
      if (code == PRE_DEC)
1013
	i = -i;
1014
      hash += (unsigned) PLUS - (unsigned)code
1015
	+ cselib_hash_rtx (XEXP (x, 0), create, memmode)
1016
	+ cselib_hash_rtx (GEN_INT (i), create, memmode);
1017
      return hash ? hash : 1 + (unsigned) PLUS;
1018
1019
    case PRE_MODIFY:
1020
      gcc_assert (memmode != VOIDmode);
1021
      return cselib_hash_rtx (XEXP (x, 1), create, memmode);
1022
914
    case POST_DEC:
1023
    case POST_DEC:
915
    case POST_INC:
1024
    case POST_INC:
916
    case POST_MODIFY:
1025
    case POST_MODIFY:
917
    case PRE_MODIFY:
1026
      gcc_assert (memmode != VOIDmode);
1027
      return cselib_hash_rtx (XEXP (x, 0), create, memmode);
1028
918
    case PC:
1029
    case PC:
919
    case CC0:
1030
    case CC0:
920
    case CALL:
1031
    case CALL:
Lines 940-946 cselib_hash_rtx (rtx x, int create) Link Here
940
	case 'e':
1051
	case 'e':
941
	  {
1052
	  {
942
	    rtx tem = XEXP (x, i);
1053
	    rtx tem = XEXP (x, i);
943
	    unsigned int tem_hash = cselib_hash_rtx (tem, create);
1054
	    unsigned int tem_hash = cselib_hash_rtx (tem, create, memmode);
944
1055
945
	    if (tem_hash == 0)
1056
	    if (tem_hash == 0)
946
	      return 0;
1057
	      return 0;
Lines 952-958 cselib_hash_rtx (rtx x, int create) Link Here
952
	  for (j = 0; j < XVECLEN (x, i); j++)
1063
	  for (j = 0; j < XVECLEN (x, i); j++)
953
	    {
1064
	    {
954
	      unsigned int tem_hash
1065
	      unsigned int tem_hash
955
		= cselib_hash_rtx (XVECEXP (x, i, j), create);
1066
		= cselib_hash_rtx (XVECEXP (x, i, j), create, memmode);
956
1067
957
	      if (tem_hash == 0)
1068
	      if (tem_hash == 0)
958
		return 0;
1069
		return 0;
Lines 1064-1070 add_mem_for_addr (cselib_val *addr_elt, Link Here
1064
static cselib_val *
1175
static cselib_val *
1065
cselib_lookup_mem (rtx x, int create)
1176
cselib_lookup_mem (rtx x, int create)
1066
{
1177
{
1067
  enum machine_mode mode = GET_MODE (x);
1178
  enum machine_mode mode = GET_MODE (x), pmode = Pmode;
1068
  void **slot;
1179
  void **slot;
1069
  cselib_val *addr;
1180
  cselib_val *addr;
1070
  cselib_val *mem_elt;
1181
  cselib_val *mem_elt;
Lines 1075-1082 cselib_lookup_mem (rtx x, int create) Link Here
1075
      || (FLOAT_MODE_P (mode) && flag_float_store))
1186
      || (FLOAT_MODE_P (mode) && flag_float_store))
1076
    return 0;
1187
    return 0;
1077
1188
1189
  if (GET_MODE (XEXP (x, 0)) != VOIDmode)
1190
    pmode = GET_MODE (XEXP (x, 0));
1191
1078
  /* Look up the value for the address.  */
1192
  /* Look up the value for the address.  */
1079
  addr = cselib_lookup (XEXP (x, 0), mode, create);
1193
  addr = cselib_lookup (XEXP (x, 0), pmode, create, mode);
1080
  if (! addr)
1194
  if (! addr)
1081
    return 0;
1195
    return 0;
1082
1196
Lines 1093-1100 cselib_lookup_mem (rtx x, int create) Link Here
1093
1207
1094
  mem_elt = new_cselib_val (next_uid, mode, x);
1208
  mem_elt = new_cselib_val (next_uid, mode, x);
1095
  add_mem_for_addr (addr, mem_elt, x);
1209
  add_mem_for_addr (addr, mem_elt, x);
1096
  slot = htab_find_slot_with_hash (cselib_hash_table, wrap_constant (mode, x),
1210
  slot = cselib_find_slot (wrap_constant (mode, x), mem_elt->hash,
1097
				   mem_elt->hash, INSERT);
1211
			   INSERT, mode);
1098
  *slot = mem_elt;
1212
  *slot = mem_elt;
1099
  return mem_elt;
1213
  return mem_elt;
1100
}
1214
}
Lines 1526-1535 cselib_expand_value_rtx_1 (rtx orig, str Link Here
1526
   with VALUE expressions.  This way, it becomes independent of changes
1640
   with VALUE expressions.  This way, it becomes independent of changes
1527
   to registers and memory.
1641
   to registers and memory.
1528
   X isn't actually modified; if modifications are needed, new rtl is
1642
   X isn't actually modified; if modifications are needed, new rtl is
1529
   allocated.  However, the return value can share rtl with X.  */
1643
   allocated.  However, the return value can share rtl with X.
1644
   If X is within a MEM, MEMMODE must be the mode of the MEM.  */
1530
1645
1531
rtx
1646
rtx
1532
cselib_subst_to_values (rtx x)
1647
cselib_subst_to_values (rtx x, enum machine_mode memmode)
1533
{
1648
{
1534
  enum rtx_code code = GET_CODE (x);
1649
  enum rtx_code code = GET_CODE (x);
1535
  const char *fmt = GET_RTX_FORMAT (code);
1650
  const char *fmt = GET_RTX_FORMAT (code);
Lines 1566-1579 cselib_subst_to_values (rtx x) Link Here
1566
    case CONST_FIXED:
1681
    case CONST_FIXED:
1567
      return x;
1682
      return x;
1568
1683
1569
    case POST_INC:
1684
    case PRE_DEC:
1570
    case PRE_INC:
1685
    case PRE_INC:
1686
      gcc_assert (memmode != VOIDmode);
1687
      i = GET_MODE_SIZE (memmode);
1688
      if (code == PRE_DEC)
1689
	i = -i;
1690
      return cselib_subst_to_values (plus_constant (XEXP (x, 0), i),
1691
				     memmode);
1692
1693
    case PRE_MODIFY:
1694
      gcc_assert (memmode != VOIDmode);
1695
      return cselib_subst_to_values (XEXP (x, 1), memmode);
1696
1571
    case POST_DEC:
1697
    case POST_DEC:
1572
    case PRE_DEC:
1698
    case POST_INC:
1573
    case POST_MODIFY:
1699
    case POST_MODIFY:
1574
    case PRE_MODIFY:
1700
      gcc_assert (memmode != VOIDmode);
1575
      e = new_cselib_val (next_uid, GET_MODE (x), x);
1701
      return cselib_subst_to_values (XEXP (x, 0), memmode);
1576
      return e->val_rtx;
1577
1702
1578
    default:
1703
    default:
1579
      break;
1704
      break;
Lines 1583-1589 cselib_subst_to_values (rtx x) Link Here
1583
    {
1708
    {
1584
      if (fmt[i] == 'e')
1709
      if (fmt[i] == 'e')
1585
	{
1710
	{
1586
	  rtx t = cselib_subst_to_values (XEXP (x, i));
1711
	  rtx t = cselib_subst_to_values (XEXP (x, i), memmode);
1587
1712
1588
	  if (t != XEXP (x, i))
1713
	  if (t != XEXP (x, i))
1589
	    {
1714
	    {
Lines 1598-1604 cselib_subst_to_values (rtx x) Link Here
1598
1723
1599
	  for (j = 0; j < XVECLEN (x, i); j++)
1724
	  for (j = 0; j < XVECLEN (x, i); j++)
1600
	    {
1725
	    {
1601
	      rtx t = cselib_subst_to_values (XVECEXP (x, i, j));
1726
	      rtx t = cselib_subst_to_values (XVECEXP (x, i, j), memmode);
1602
1727
1603
	      if (t != XVECEXP (x, i, j))
1728
	      if (t != XVECEXP (x, i, j))
1604
		{
1729
		{
Lines 1617-1629 cselib_subst_to_values (rtx x) Link Here
1617
  return copy;
1742
  return copy;
1618
}
1743
}
1619
1744
1620
/* Look up the rtl expression X in our tables and return the value it has.
1745
/* Look up the rtl expression X in our tables and return the value it
1621
   If CREATE is zero, we return NULL if we don't know the value.  Otherwise,
1746
   has.  If CREATE is zero, we return NULL if we don't know the value.
1622
   we create a new one if possible, using mode MODE if X doesn't have a mode
1747
   Otherwise, we create a new one if possible, using mode MODE if X
1623
   (i.e. because it's a constant).  */
1748
   doesn't have a mode (i.e. because it's a constant).  When X is part
1749
   of an address, MEMMODE should be the mode of the enclosing MEM if
1750
   we're tracking autoinc expressions.  */
1624
1751
1625
static cselib_val *
1752
static cselib_val *
1626
cselib_lookup_1 (rtx x, enum machine_mode mode, int create)
1753
cselib_lookup_1 (rtx x, enum machine_mode mode,
1754
		 int create, enum machine_mode memmode)
1627
{
1755
{
1628
  void **slot;
1756
  void **slot;
1629
  cselib_val *e;
1757
  cselib_val *e;
Lines 1672-1678 cselib_lookup_1 (rtx x, enum machine_mod Link Here
1672
	  REG_VALUES (i) = new_elt_list (REG_VALUES (i), NULL);
1800
	  REG_VALUES (i) = new_elt_list (REG_VALUES (i), NULL);
1673
	}
1801
	}
1674
      REG_VALUES (i)->next = new_elt_list (REG_VALUES (i)->next, e);
1802
      REG_VALUES (i)->next = new_elt_list (REG_VALUES (i)->next, e);
1675
      slot = htab_find_slot_with_hash (cselib_hash_table, x, e->hash, INSERT);
1803
      slot = cselib_find_slot (x, e->hash, INSERT, memmode);
1676
      *slot = e;
1804
      *slot = e;
1677
      return e;
1805
      return e;
1678
    }
1806
    }
Lines 1680-1692 cselib_lookup_1 (rtx x, enum machine_mod Link Here
1680
  if (MEM_P (x))
1808
  if (MEM_P (x))
1681
    return cselib_lookup_mem (x, create);
1809
    return cselib_lookup_mem (x, create);
1682
1810
1683
  hashval = cselib_hash_rtx (x, create);
1811
  hashval = cselib_hash_rtx (x, create, memmode);
1684
  /* Can't even create if hashing is not possible.  */
1812
  /* Can't even create if hashing is not possible.  */
1685
  if (! hashval)
1813
  if (! hashval)
1686
    return 0;
1814
    return 0;
1687
1815
1688
  slot = htab_find_slot_with_hash (cselib_hash_table, wrap_constant (mode, x),
1816
  slot = cselib_find_slot (wrap_constant (mode, x), hashval,
1689
				   hashval, create ? INSERT : NO_INSERT);
1817
			   create ? INSERT : NO_INSERT, memmode);
1690
  if (slot == 0)
1818
  if (slot == 0)
1691
    return 0;
1819
    return 0;
1692
1820
Lines 1700-1706 cselib_lookup_1 (rtx x, enum machine_mod Link Here
1700
     the hash table is inconsistent until we do so, and
1828
     the hash table is inconsistent until we do so, and
1701
     cselib_subst_to_values will need to do lookups.  */
1829
     cselib_subst_to_values will need to do lookups.  */
1702
  *slot = (void *) e;
1830
  *slot = (void *) e;
1703
  e->locs = new_elt_loc_list (e->locs, cselib_subst_to_values (x));
1831
  e->locs = new_elt_loc_list (e->locs,
1832
			      cselib_subst_to_values (x, memmode));
1704
  return e;
1833
  return e;
1705
}
1834
}
1706
1835
Lines 1708-1721 cselib_lookup_1 (rtx x, enum machine_mod Link Here
1708
1837
1709
cselib_val *
1838
cselib_val *
1710
cselib_lookup_from_insn (rtx x, enum machine_mode mode,
1839
cselib_lookup_from_insn (rtx x, enum machine_mode mode,
1711
			 int create, rtx insn)
1840
			 int create, enum machine_mode memmode, rtx insn)
1712
{
1841
{
1713
  cselib_val *ret;
1842
  cselib_val *ret;
1714
1843
1715
  gcc_assert (!cselib_current_insn);
1844
  gcc_assert (!cselib_current_insn);
1716
  cselib_current_insn = insn;
1845
  cselib_current_insn = insn;
1717
1846
1718
  ret = cselib_lookup (x, mode, create);
1847
  ret = cselib_lookup (x, mode, create, memmode);
1719
1848
1720
  cselib_current_insn = NULL;
1849
  cselib_current_insn = NULL;
1721
1850
Lines 1726-1734 cselib_lookup_from_insn (rtx x, enum mac Link Here
1726
   maintains invariants related with debug insns.  */
1855
   maintains invariants related with debug insns.  */
1727
1856
1728
cselib_val *
1857
cselib_val *
1729
cselib_lookup (rtx x, enum machine_mode mode, int create)
1858
cselib_lookup (rtx x, enum machine_mode mode,
1859
	       int create, enum machine_mode memmode)
1730
{
1860
{
1731
  cselib_val *ret = cselib_lookup_1 (x, mode, create);
1861
  cselib_val *ret = cselib_lookup_1 (x, mode, create, memmode);
1732
1862
1733
  /* ??? Should we return NULL if we're not to create an entry, the
1863
  /* ??? Should we return NULL if we're not to create an entry, the
1734
     found loc is a debug loc and cselib_current_insn is not DEBUG?
1864
     found loc is a debug loc and cselib_current_insn is not DEBUG?
Lines 1913-1919 cselib_invalidate_mem (rtx mem_rtx) Link Here
1913
	  /* This one overlaps.  */
2043
	  /* This one overlaps.  */
1914
	  /* We must have a mapping from this MEM's address to the
2044
	  /* We must have a mapping from this MEM's address to the
1915
	     value (E).  Remove that, too.  */
2045
	     value (E).  Remove that, too.  */
1916
	  addr = cselib_lookup (XEXP (x, 0), VOIDmode, 0);
2046
	  addr = cselib_lookup (XEXP (x, 0), VOIDmode, 0, GET_MODE (x));
1917
	  mem_chain = &addr->addr_list;
2047
	  mem_chain = &addr->addr_list;
1918
	  for (;;)
2048
	  for (;;)
1919
	    {
2049
	    {
Lines 1963-1975 cselib_invalidate_rtx (rtx dest) Link Here
1963
    cselib_invalidate_regno (REGNO (dest), GET_MODE (dest));
2093
    cselib_invalidate_regno (REGNO (dest), GET_MODE (dest));
1964
  else if (MEM_P (dest))
2094
  else if (MEM_P (dest))
1965
    cselib_invalidate_mem (dest);
2095
    cselib_invalidate_mem (dest);
1966
1967
  /* Some machines don't define AUTO_INC_DEC, but they still use push
1968
     instructions.  We need to catch that case here in order to
1969
     invalidate the stack pointer correctly.  Note that invalidating
1970
     the stack pointer is different from invalidating DEST.  */
1971
  if (push_operand (dest, GET_MODE (dest)))
1972
    cselib_invalidate_rtx (stack_pointer_rtx);
1973
}
2096
}
1974
2097
1975
/* A wrapper for cselib_invalidate_rtx to be called via note_stores.  */
2098
/* A wrapper for cselib_invalidate_rtx to be called via note_stores.  */
Lines 2032-2037 cselib_record_set (rtx dest, cselib_val Link Here
2032
   in a PARALLEL.  Since it's fairly cheap, use a really large number.  */
2155
   in a PARALLEL.  Since it's fairly cheap, use a really large number.  */
2033
#define MAX_SETS (FIRST_PSEUDO_REGISTER * 2)
2156
#define MAX_SETS (FIRST_PSEUDO_REGISTER * 2)
2034
2157
2158
struct cselib_record_autoinc_data
2159
{
2160
  struct cselib_set *sets;
2161
  int n_sets;
2162
};
2163
2164
/* Callback for for_each_inc_dec.  Records in ARG the SETs implied by
2165
   autoinc RTXs: SRCBASE plus SRCOFF if non-NULL is stored in
2166
   DEST.  */
2167
2168
static int
2169
cselib_record_autoinc_cb (rtx mem ATTRIBUTE_UNUSED, rtx op ATTRIBUTE_UNUSED,
2170
			  rtx dest, rtx srcbase, rtx srcoff, void *arg)
2171
{
2172
  struct cselib_record_autoinc_data *data;
2173
  data = (struct cselib_record_autoinc_data *)arg;
2174
2175
  data->sets[data->n_sets].dest = dest;
2176
2177
  if (srcoff)
2178
    data->sets[data->n_sets].src = gen_rtx_PLUS (GET_MODE (srcbase),
2179
						 srcbase, srcoff);
2180
  else
2181
    data->sets[data->n_sets].src = srcbase;
2182
2183
  data->n_sets++;
2184
2185
  return -1;
2186
}
2187
2035
/* Record the effects of any sets in INSN.  */
2188
/* Record the effects of any sets in INSN.  */
2036
static void
2189
static void
2037
cselib_record_sets (rtx insn)
2190
cselib_record_sets (rtx insn)
Lines 2041-2046 cselib_record_sets (rtx insn) Link Here
2041
  struct cselib_set sets[MAX_SETS];
2194
  struct cselib_set sets[MAX_SETS];
2042
  rtx body = PATTERN (insn);
2195
  rtx body = PATTERN (insn);
2043
  rtx cond = 0;
2196
  rtx cond = 0;
2197
  int n_sets_before_autoinc;
2198
  struct cselib_record_autoinc_data data;
2044
2199
2045
  body = PATTERN (insn);
2200
  body = PATTERN (insn);
2046
  if (GET_CODE (body) == COND_EXEC)
2201
  if (GET_CODE (body) == COND_EXEC)
Lines 2084-2089 cselib_record_sets (rtx insn) Link Here
2084
	sets[0].src = XEXP (note, 0);
2239
	sets[0].src = XEXP (note, 0);
2085
    }
2240
    }
2086
2241
2242
  data.sets = sets;
2243
  data.n_sets = n_sets_before_autoinc = n_sets;
2244
  for_each_inc_dec (&insn, cselib_record_autoinc_cb, &data);
2245
  n_sets = data.n_sets;
2246
2087
  /* Look up the values that are read.  Do this before invalidating the
2247
  /* Look up the values that are read.  Do this before invalidating the
2088
     locations that are written.  */
2248
     locations that are written.  */
2089
  for (i = 0; i < n_sets; i++)
2249
  for (i = 0; i < n_sets; i++)
Lines 2102-2115 cselib_record_sets (rtx insn) Link Here
2102
	  rtx src = sets[i].src;
2262
	  rtx src = sets[i].src;
2103
	  if (cond)
2263
	  if (cond)
2104
	    src = gen_rtx_IF_THEN_ELSE (GET_MODE (dest), cond, src, dest);
2264
	    src = gen_rtx_IF_THEN_ELSE (GET_MODE (dest), cond, src, dest);
2105
	  sets[i].src_elt = cselib_lookup (src, GET_MODE (dest), 1);
2265
	  sets[i].src_elt = cselib_lookup (src, GET_MODE (dest), 1, VOIDmode);
2106
	  if (MEM_P (dest))
2266
	  if (MEM_P (dest))
2107
	    {
2267
	    {
2108
	      enum machine_mode address_mode
2268
	      enum machine_mode address_mode
2109
		= targetm.addr_space.address_mode (MEM_ADDR_SPACE (dest));
2269
		= targetm.addr_space.address_mode (MEM_ADDR_SPACE (dest));
2110
2270
2111
	      sets[i].dest_addr_elt = cselib_lookup (XEXP (dest, 0),
2271
	      sets[i].dest_addr_elt = cselib_lookup (XEXP (dest, 0),
2112
						     address_mode, 1);
2272
						     address_mode, 1,
2273
						     GET_MODE (dest));
2113
	    }
2274
	    }
2114
	  else
2275
	  else
2115
	    sets[i].dest_addr_elt = 0;
2276
	    sets[i].dest_addr_elt = 0;
Lines 2124-2129 cselib_record_sets (rtx insn) Link Here
2124
     locations may go away.  */
2285
     locations may go away.  */
2125
  note_stores (body, cselib_invalidate_rtx_note_stores, NULL);
2286
  note_stores (body, cselib_invalidate_rtx_note_stores, NULL);
2126
2287
2288
  for (i = n_sets_before_autoinc; i < n_sets; i++)
2289
    cselib_invalidate_rtx (sets[i].dest);
2290
2127
  /* If this is an asm, look for duplicate sets.  This can happen when the
2291
  /* If this is an asm, look for duplicate sets.  This can happen when the
2128
     user uses the same value as an output multiple times.  This is valid
2292
     user uses the same value as an output multiple times.  This is valid
2129
     if the outputs are not actually used thereafter.  Treat this case as
2293
     if the outputs are not actually used thereafter.  Treat this case as
(-)gcc/var-tracking.c.orig (-18 / +30 lines)
Lines 737-743 use_narrower_mode_test (rtx *loc, void * Link Here
737
  switch (GET_CODE (*loc))
737
  switch (GET_CODE (*loc))
738
    {
738
    {
739
    case REG:
739
    case REG:
740
      if (cselib_lookup (*loc, GET_MODE (SUBREG_REG (subreg)), 0))
740
      if (cselib_lookup (*loc, GET_MODE (SUBREG_REG (subreg)), 0, VOIDmode))
741
	return 1;
741
	return 1;
742
      return -1;
742
      return -1;
743
    case PLUS:
743
    case PLUS:
Lines 3954-3961 variable_post_merge_new_vals (void **slo Link Here
3954
			 subsequent rounds.  */
3954
			 subsequent rounds.  */
3955
		      cselib_val *v;
3955
		      cselib_val *v;
3956
		      gcc_assert (!cselib_lookup (node->loc,
3956
		      gcc_assert (!cselib_lookup (node->loc,
3957
						  GET_MODE (node->loc), 0));
3957
						  GET_MODE (node->loc), 0,
3958
		      v = cselib_lookup (node->loc, GET_MODE (node->loc), 1);
3958
						  VOIDmode));
3959
		      v = cselib_lookup (node->loc, GET_MODE (node->loc), 1,
3960
					 VOIDmode);
3959
		      cselib_preserve_value (v);
3961
		      cselib_preserve_value (v);
3960
		      cselib_invalidate_rtx (node->loc);
3962
		      cselib_invalidate_rtx (node->loc);
3961
		      cval = v->val_rtx;
3963
		      cval = v->val_rtx;
Lines 4793-4799 find_use_val (rtx x, enum machine_mode m Link Here
4793
	      return cui->sets[i].src_elt;
4795
	      return cui->sets[i].src_elt;
4794
	}
4796
	}
4795
      else
4797
      else
4796
	return cselib_lookup (x, mode, 0);
4798
	return cselib_lookup (x, mode, 0, VOIDmode);
4797
    }
4799
    }
4798
4800
4799
  return NULL;
4801
  return NULL;
Lines 4822-4835 replace_expr_with_values (rtx loc) Link Here
4822
  else if (MEM_P (loc))
4824
  else if (MEM_P (loc))
4823
    {
4825
    {
4824
      cselib_val *addr = cselib_lookup (XEXP (loc, 0),
4826
      cselib_val *addr = cselib_lookup (XEXP (loc, 0),
4825
					get_address_mode (loc), 0);
4827
					get_address_mode (loc), 0,
4828
					GET_MODE (loc));
4826
      if (addr)
4829
      if (addr)
4827
	return replace_equiv_address_nv (loc, addr->val_rtx);
4830
	return replace_equiv_address_nv (loc, addr->val_rtx);
4828
      else
4831
      else
4829
	return NULL;
4832
	return NULL;
4830
    }
4833
    }
4831
  else
4834
  else
4832
    return cselib_subst_to_values (loc);
4835
    return cselib_subst_to_values (loc, VOIDmode);
4833
}
4836
}
4834
4837
4835
/* Determine what kind of micro operation to choose for a USE.  Return
4838
/* Determine what kind of micro operation to choose for a USE.  Return
Lines 4849-4855 use_type (rtx loc, struct count_use_info Link Here
4849
	      rtx ploc = PAT_VAR_LOCATION_LOC (loc);
4852
	      rtx ploc = PAT_VAR_LOCATION_LOC (loc);
4850
	      if (! VAR_LOC_UNKNOWN_P (ploc))
4853
	      if (! VAR_LOC_UNKNOWN_P (ploc))
4851
		{
4854
		{
4852
		  cselib_val *val = cselib_lookup (ploc, GET_MODE (loc), 1);
4855
		  cselib_val *val = cselib_lookup (ploc, GET_MODE (loc), 1,
4856
						   VOIDmode);
4853
4857
4854
		  /* ??? flag_float_store and volatile mems are never
4858
		  /* ??? flag_float_store and volatile mems are never
4855
		     given values, but we could in theory use them for
4859
		     given values, but we could in theory use them for
Lines 4871-4877 use_type (rtx loc, struct count_use_info Link Here
4871
	      if (REG_P (loc)
4875
	      if (REG_P (loc)
4872
		  || (find_use_val (loc, GET_MODE (loc), cui)
4876
		  || (find_use_val (loc, GET_MODE (loc), cui)
4873
		      && cselib_lookup (XEXP (loc, 0),
4877
		      && cselib_lookup (XEXP (loc, 0),
4874
					get_address_mode (loc), 0)))
4878
					get_address_mode (loc), 0,
4879
					GET_MODE (loc))))
4875
		return MO_VAL_SET;
4880
		return MO_VAL_SET;
4876
	    }
4881
	    }
4877
	  else
4882
	  else
Lines 5033-5045 add_uses (rtx *ploc, void *data) Link Here
5033
	      rtx mloc = vloc;
5038
	      rtx mloc = vloc;
5034
	      enum machine_mode address_mode = get_address_mode (mloc);
5039
	      enum machine_mode address_mode = get_address_mode (mloc);
5035
	      cselib_val *val
5040
	      cselib_val *val
5036
		= cselib_lookup (XEXP (mloc, 0), address_mode, 0);
5041
		= cselib_lookup (XEXP (mloc, 0), address_mode, 0,
5042
				 GET_MODE (mloc));
5037
5043
5038
	      if (val && !cselib_preserved_value_p (val))
5044
	      if (val && !cselib_preserved_value_p (val))
5039
		{
5045
		{
5040
		  micro_operation moa;
5046
		  micro_operation moa;
5041
		  preserve_value (val);
5047
		  preserve_value (val);
5042
		  mloc = cselib_subst_to_values (XEXP (mloc, 0));
5048
		  mloc = cselib_subst_to_values (XEXP (mloc, 0),
5049
						 GET_MODE (mloc));
5043
		  moa.type = MO_VAL_USE;
5050
		  moa.type = MO_VAL_USE;
5044
		  moa.insn = cui->insn;
5051
		  moa.insn = cui->insn;
5045
		  moa.u.loc = gen_rtx_CONCAT (address_mode,
5052
		  moa.u.loc = gen_rtx_CONCAT (address_mode,
Lines 5109-5121 add_uses (rtx *ploc, void *data) Link Here
5109
	      rtx mloc = oloc;
5116
	      rtx mloc = oloc;
5110
	      enum machine_mode address_mode = get_address_mode (mloc);
5117
	      enum machine_mode address_mode = get_address_mode (mloc);
5111
	      cselib_val *val
5118
	      cselib_val *val
5112
		= cselib_lookup (XEXP (mloc, 0), address_mode, 0);
5119
		= cselib_lookup (XEXP (mloc, 0), address_mode, 0,
5120
				GET_MODE (mloc));
5113
5121
5114
	      if (val && !cselib_preserved_value_p (val))
5122
	      if (val && !cselib_preserved_value_p (val))
5115
		{
5123
		{
5116
		  micro_operation moa;
5124
		  micro_operation moa;
5117
		  preserve_value (val);
5125
		  preserve_value (val);
5118
		  mloc = cselib_subst_to_values (XEXP (mloc, 0));
5126
		  mloc = cselib_subst_to_values (XEXP (mloc, 0),
5127
						GET_MODE (mloc));
5119
		  moa.type = MO_VAL_USE;
5128
		  moa.type = MO_VAL_USE;
5120
		  moa.insn = cui->insn;
5129
		  moa.insn = cui->insn;
5121
		  moa.u.loc = gen_rtx_CONCAT (address_mode,
5130
		  moa.u.loc = gen_rtx_CONCAT (address_mode,
Lines 5225-5231 reverse_op (rtx val, const_rtx expr) Link Here
5225
  if (!SCALAR_INT_MODE_P (GET_MODE (src)) || XEXP (src, 0) == cfa_base_rtx)
5234
  if (!SCALAR_INT_MODE_P (GET_MODE (src)) || XEXP (src, 0) == cfa_base_rtx)
5226
    return NULL_RTX;
5235
    return NULL_RTX;
5227
5236
5228
  v = cselib_lookup (XEXP (src, 0), GET_MODE (XEXP (src, 0)), 0);
5237
  v = cselib_lookup (XEXP (src, 0), GET_MODE (XEXP (src, 0)), 0, VOIDmode);
5229
  if (!v || !cselib_preserved_value_p (v))
5238
  if (!v || !cselib_preserved_value_p (v))
5230
    return NULL_RTX;
5239
    return NULL_RTX;
5231
5240
Lines 5346-5358 add_stores (rtx loc, const_rtx expr, voi Link Here
5346
	  rtx mloc = loc;
5355
	  rtx mloc = loc;
5347
	  enum machine_mode address_mode = get_address_mode (mloc);
5356
	  enum machine_mode address_mode = get_address_mode (mloc);
5348
	  cselib_val *val = cselib_lookup (XEXP (mloc, 0),
5357
	  cselib_val *val = cselib_lookup (XEXP (mloc, 0),
5349
					   address_mode, 0);
5358
					   address_mode, 0,
5359
					   GET_MODE (mloc));
5350
5360
5351
	  if (val && !cselib_preserved_value_p (val))
5361
	  if (val && !cselib_preserved_value_p (val))
5352
	    {
5362
	    {
5353
	      preserve_value (val);
5363
	      preserve_value (val);
5354
	      mo.type = MO_VAL_USE;
5364
	      mo.type = MO_VAL_USE;
5355
	      mloc = cselib_subst_to_values (XEXP (mloc, 0));
5365
	      mloc = cselib_subst_to_values (XEXP (mloc, 0),
5366
					     GET_MODE (mloc));
5356
	      mo.u.loc = gen_rtx_CONCAT (address_mode, val->val_rtx, mloc);
5367
	      mo.u.loc = gen_rtx_CONCAT (address_mode, val->val_rtx, mloc);
5357
	      mo.insn = cui->insn;
5368
	      mo.insn = cui->insn;
5358
	      if (dump_file && (dump_flags & TDF_DETAILS))
5369
	      if (dump_file && (dump_flags & TDF_DETAILS))
Lines 5411-5417 add_stores (rtx loc, const_rtx expr, voi Link Here
5411
5422
5412
  if (GET_CODE (PATTERN (cui->insn)) == COND_EXEC)
5423
  if (GET_CODE (PATTERN (cui->insn)) == COND_EXEC)
5413
    {
5424
    {
5414
      cselib_val *oval = cselib_lookup (oloc, GET_MODE (oloc), 0);
5425
      cselib_val *oval = cselib_lookup (oloc, GET_MODE (oloc), 0, VOIDmode);
5415
5426
5416
      gcc_assert (oval != v);
5427
      gcc_assert (oval != v);
5417
      gcc_assert (REG_P (oloc) || MEM_P (oloc));
5428
      gcc_assert (REG_P (oloc) || MEM_P (oloc));
Lines 8077-8083 vt_add_function_parameter (tree parm) Link Here
8077
      if (offset)
8088
      if (offset)
8078
	return;
8089
	return;
8079
8090
8080
      val = cselib_lookup (var_lowpart (mode, incoming), mode, true);
8091
      val = cselib_lookup (var_lowpart (mode, incoming), mode, true,
8092
			   VOIDmode);
8081
8093
8082
      /* ??? Float-typed values in memory are not handled by
8094
      /* ??? Float-typed values in memory are not handled by
8083
	 cselib.  */
8095
	 cselib.  */
Lines 8197-8203 vt_init_cfa_base (void) Link Here
8197
			    frame_pointer_needed
8209
			    frame_pointer_needed
8198
			    ? hard_frame_pointer_rtx : stack_pointer_rtx);
8210
			    ? hard_frame_pointer_rtx : stack_pointer_rtx);
8199
  val = cselib_lookup_from_insn (cfa_base_rtx, GET_MODE (cfa_base_rtx), 1,
8211
  val = cselib_lookup_from_insn (cfa_base_rtx, GET_MODE (cfa_base_rtx), 1,
8200
				 get_insns ());
8212
				 VOIDmode, get_insns ());
8201
  preserve_value (val);
8213
  preserve_value (val);
8202
  cselib_preserve_cfa_base_value (val, REGNO (cfa_base_rtx));
8214
  cselib_preserve_cfa_base_value (val, REGNO (cfa_base_rtx));
8203
  var_reg_decl_set (&VTI (ENTRY_BLOCK_PTR)->out, cfa_base_rtx,
8215
  var_reg_decl_set (&VTI (ENTRY_BLOCK_PTR)->out, cfa_base_rtx,
(-)gcc/sched-deps.c.orig (-5 / +7 lines)
Lines 1566-1572 add_insn_mem_dependence (struct deps_des Link Here
1566
  if (sched_deps_info->use_cselib)
1566
  if (sched_deps_info->use_cselib)
1567
    {
1567
    {
1568
      mem = shallow_copy_rtx (mem);
1568
      mem = shallow_copy_rtx (mem);
1569
      XEXP (mem, 0) = cselib_subst_to_values (XEXP (mem, 0));
1569
      XEXP (mem, 0) = cselib_subst_to_values (XEXP (mem, 0), GET_MODE (mem));
1570
    }
1570
    }
1571
  link = alloc_EXPR_LIST (VOIDmode, canon_rtx (mem), *mem_list);
1571
  link = alloc_EXPR_LIST (VOIDmode, canon_rtx (mem), *mem_list);
1572
  *mem_list = link;
1572
  *mem_list = link;
Lines 2283-2290 sched_analyze_1 (struct deps_desc *deps, Link Here
2283
	    = targetm.addr_space.address_mode (MEM_ADDR_SPACE (dest));
2283
	    = targetm.addr_space.address_mode (MEM_ADDR_SPACE (dest));
2284
2284
2285
	  t = shallow_copy_rtx (dest);
2285
	  t = shallow_copy_rtx (dest);
2286
	  cselib_lookup_from_insn (XEXP (t, 0), address_mode, 1, insn);
2286
	  cselib_lookup_from_insn (XEXP (t, 0), address_mode, 1,
2287
	  XEXP (t, 0) = cselib_subst_to_values (XEXP (t, 0));
2287
				   GET_MODE (t), insn);
2288
	  XEXP (t, 0) = cselib_subst_to_values (XEXP (t, 0), GET_MODE (t));
2288
	}
2289
	}
2289
      t = canon_rtx (t);
2290
      t = canon_rtx (t);
2290
2291
Lines 2440-2447 sched_analyze_2 (struct deps_desc *deps, Link Here
2440
	      = targetm.addr_space.address_mode (MEM_ADDR_SPACE (t));
2441
	      = targetm.addr_space.address_mode (MEM_ADDR_SPACE (t));
2441
2442
2442
	    t = shallow_copy_rtx (t);
2443
	    t = shallow_copy_rtx (t);
2443
	    cselib_lookup_from_insn (XEXP (t, 0), address_mode, 1, insn);
2444
	    cselib_lookup_from_insn (XEXP (t, 0), address_mode, 1,
2444
	    XEXP (t, 0) = cselib_subst_to_values (XEXP (t, 0));
2445
				     GET_MODE (t), insn);
2446
	    XEXP (t, 0) = cselib_subst_to_values (XEXP (t, 0), GET_MODE (t));
2445
	  }
2447
	  }
2446
2448
2447
	if (!DEBUG_INSN_P (insn))
2449
	if (!DEBUG_INSN_P (insn))
(-)gcc/gcse.c.orig (-1 / +1 lines)
Lines 2738-2744 do_local_cprop (rtx x, rtx insn) Link Here
2738
          || (GET_CODE (PATTERN (insn)) != USE
2738
          || (GET_CODE (PATTERN (insn)) != USE
2739
	      && asm_noperands (PATTERN (insn)) < 0)))
2739
	      && asm_noperands (PATTERN (insn)) < 0)))
2740
    {
2740
    {
2741
      cselib_val *val = cselib_lookup (x, GET_MODE (x), 0);
2741
      cselib_val *val = cselib_lookup (x, GET_MODE (x), 0, VOIDmode);
2742
      struct elt_loc_list *l;
2742
      struct elt_loc_list *l;
2743
2743
2744
      if (!val)
2744
      if (!val)
(-)gcc/postreload.c.orig (-2 / +2 lines)
Lines 262-268 reload_cse_simplify_set (rtx set, rtx in Link Here
262
    return 0;
262
    return 0;
263
#endif
263
#endif
264
264
265
  val = cselib_lookup (src, GET_MODE (SET_DEST (set)), 0);
265
  val = cselib_lookup (src, GET_MODE (SET_DEST (set)), 0, VOIDmode);
266
  if (! val)
266
  if (! val)
267
    return 0;
267
    return 0;
268
268
Lines 476-482 reload_cse_simplify_operands (rtx insn, Link Here
476
	    continue;
476
	    continue;
477
	}
477
	}
478
#endif /* LOAD_EXTEND_OP */
478
#endif /* LOAD_EXTEND_OP */
479
      v = cselib_lookup (op, recog_data.operand_mode[i], 0);
479
      v =  cselib_lookup (op, recog_data.operand_mode[i], 0, VOIDmode);
480
      if (! v)
480
      if (! v)
481
	continue;
481
	continue;
482
482
(-)gcc/sel-sched-dump.c.orig (-2 / +2 lines)
Lines 960-967 debug_mem_addr_value (rtx x) Link Here
960
  address_mode = targetm.addr_space.address_mode (MEM_ADDR_SPACE (x));
960
  address_mode = targetm.addr_space.address_mode (MEM_ADDR_SPACE (x));
961
961
962
  t = shallow_copy_rtx (x);
962
  t = shallow_copy_rtx (x);
963
  if (cselib_lookup (XEXP (t, 0), address_mode, 0))
963
  if (cselib_lookup (XEXP (t, 0), address_mode, 0, GET_MODE (t)))
964
    XEXP (t, 0) = cselib_subst_to_values (XEXP (t, 0));
964
    XEXP (t, 0) = cselib_subst_to_values (XEXP (t, 0), GET_MODE (t));
965
965
966
  t = canon_rtx (t);
966
  t = canon_rtx (t);
967
  addr = get_addr (XEXP (t, 0));
967
  addr = get_addr (XEXP (t, 0));

Return to bug 43494