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] for PR16807


Hello,

this problem was caused by the fact that invariants of form

extend (subreg (reg)) + const

were expressed in rtx_iv with const set in delta field, with mode and
extend_mode set appropriatelly.  Which is OK, but some of the code in
the # of iterations analysis does not expect that and instead assumes
that the whole expression will be set in base field.

Given that the later is more powerful, this patch modifies iv_subreg
and iv_extend so that they express the invariants in the desired form.

The PR is for lno-branch only, but the same problem of course is in
mainline as well, so I need approval for the patch.

Bootstrapped & regtested on ia64.

Zdenek

	PR tree-optimization/16807
	* loop-iv.c (dump_iv_info): Dump invariants correctly.
	(iv_subreg, iv_extend): Express value of invariant purely in
	base field.

Index: loop-iv.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-iv.c,v
retrieving revision 1.1.4.13
diff -c -3 -p -r1.1.4.13 loop-iv.c
*** loop-iv.c	18 Jul 2004 23:13:17 -0000	1.1.4.13
--- loop-iv.c	30 Jul 2004 14:36:07 -0000
*************** dump_iv_info (FILE *file, struct rtx_iv 
*** 104,120 ****
        return;
      }
  
!   if (iv->step == const0_rtx)
!     {
!       fprintf (file, "invariant ");
!       print_rtl (file, iv->base);
!       return;
!     }
  
    print_rtl (file, iv->base);
!   fprintf (file, " + ");
!   print_rtl (file, iv->step);
!   fprintf (file, " * iteration");
    fprintf (file, " (in %s)", GET_MODE_NAME (iv->mode));
  
    if (iv->mode != iv->extend_mode)
--- 104,120 ----
        return;
      }
  
!   if (iv->step == const0_rtx
!       && !iv->first_special)
!     fprintf (file, "invariant ");
  
    print_rtl (file, iv->base);
!   if (iv->step != const0_rtx)
!     {
!       fprintf (file, " + ");
!       print_rtl (file, iv->step);
!       fprintf (file, " * iteration");
!     }
    fprintf (file, " (in %s)", GET_MODE_NAME (iv->mode));
  
    if (iv->mode != iv->extend_mode)
*************** iv_constant (struct rtx_iv *iv, rtx cst,
*** 440,445 ****
--- 440,460 ----
  static bool
  iv_subreg (struct rtx_iv *iv, enum machine_mode mode)
  {
+   /* If iv is invariant, just calculate the new value.  */
+   if (iv->step == const0_rtx
+       && !iv->first_special)
+     {
+       rtx val = get_iv_value (iv, const0_rtx);
+       val = lowpart_subreg (mode, val, iv->extend_mode);
+ 
+       iv->base = val;
+       iv->extend = NIL;
+       iv->mode = iv->extend_mode = mode;
+       iv->delta = const0_rtx;
+       iv->mult = const1_rtx;
+       return true;
+     }
+ 
    if (iv->extend_mode == mode)
      return true;
  
*************** iv_subreg (struct rtx_iv *iv, enum machi
*** 465,470 ****
--- 480,500 ----
  static bool
  iv_extend (struct rtx_iv *iv, enum rtx_code extend, enum machine_mode mode)
  {
+   /* If iv is invariant, just calculate the new value.  */
+   if (iv->step == const0_rtx
+       && !iv->first_special)
+     {
+       rtx val = get_iv_value (iv, const0_rtx);
+       val = simplify_gen_unary (extend, mode, val, iv->extend_mode);
+ 
+       iv->base = val;
+       iv->extend = NIL;
+       iv->mode = iv->extend_mode = mode;
+       iv->delta = const0_rtx;
+       iv->mult = const1_rtx;
+       return true;
+     }
+ 
    if (mode != iv->extend_mode)
      return false;
  


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