public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Corey Minyard <minyard@acm.org>
To: Richard Henderson <rth@redhat.com>
Cc: gcc@gcc.gnu.org
Subject: Re: Loop optimization bug with Ada front end on PPC (and probably Alpha)
Date: Mon, 19 Nov 2001 12:44:00 -0000	[thread overview]
Message-ID: <3C041C3F.3030508@acm.org> (raw)
In-Reply-To: <20011127142713.A30195@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 621 bytes --]



Richard Henderson wrote:

>On Tue, Nov 27, 2001 at 03:26:43PM -0600, Corey Minyard wrote:
>
>>Are you moving back to the original loop test?  I think the original 
>>test you had didn't work because it wasn't the doloop case, but if you 
>>put it in the doloop code it should work properly.
>>
>
>I'm taking out the CONT test, yes.  But I'm keeping the LUID
>test against the BIV initializer rather than scanning with
>reg_set_between_p.
>
You will need to set the bl variable a little differently, in case its a 
GIV.  I've attached a patch.  That was the cause of my segv earlier. 
 Bootstrapping again....

-Corey



[-- Attachment #1.2: Type: text/html, Size: 1027 bytes --]

[-- Attachment #2: gcc-ppc5.diff --]
[-- Type: text/plain, Size: 2290 bytes --]

Index: doloop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doloop.c,v
retrieving revision 1.12
diff -u -p -r1.12 doloop.c
--- doloop.c	2001/11/16 02:26:38	1.12
+++ doloop.c	2001/11/27 23:01:46
@@ -596,6 +596,59 @@ doloop_modify_runtime (loop, iterations_
 			      copy_rtx (neg_inc ? final_value : initial_value),
 			      NULL_RTX, unsigned_p, OPTAB_LIB_WIDEN);
 
+  /* Some code transformations can result in code akin to
+
+	  tmp = i + 1;
+	  ...
+	  goto scan_start;
+	top:
+	  tmp = tmp + 1;
+	scan_start:
+	  i = tmp;
+	  if (i < n) goto top;
+
+     We'll have already detected this form of loop in scan_loop,
+     and set loop->top and loop->scan_start appropriately.
+
+     In this situation, we skip the increment the first time through
+     the loop, which results in an incorrect estimate of the number
+     of iterations.  Adjust the difference to compensate.  */
+  /* ??? Logically, it would seem this belongs in loop_iterations.
+     However, this causes regressions e.g. on x86 execute/20011008-3.c,
+     so I do not believe we've properly characterized the exact nature
+     of the problem.  In the meantime, this fixes execute/20011126-2.c
+     on ia64 and some Ada front end miscompilation on ppc.  */
+
+  if (loop->scan_start)
+    {
+      rtx iteration_var;
+      struct loop_ivs *ivs = LOOP_IVS (loop);
+      struct iv_class *bl;
+
+      iteration_var = loop_info->iteration_var;
+
+      if (REG_IV_TYPE (ivs, REGNO (iteration_var)) == BASIC_INDUCT)
+	bl = REG_IV_CLASS (ivs, REGNO (iteration_var));
+      else if (REG_IV_TYPE (ivs, REGNO (iteration_var)) == GENERAL_INDUCT)
+	{
+	  struct induction *v = REG_IV_INFO (ivs, REGNO (iteration_var));
+	  bl = REG_IV_CLASS (ivs, REGNO (v->src_reg));
+	}
+      else
+	abort(); /* iteration var must be an induction variable to get
+		    to here. */
+
+      if (INSN_LUID (bl->biv->insn) < INSN_LUID (loop->scan_start))
+	{
+	  if (loop_dump_stream)
+	    fprintf (loop_dump_stream,
+	         "Doloop: Basic induction var skips initial incr.\n");
+
+	  diff = expand_simple_binop (mode, PLUS, diff, increment, diff,
+				      unsigned_p, OPTAB_LIB_WIDEN);
+	}
+    }
+
   if (abs_inc * loop_info->unroll_number != 1)
     {
       int shift_count;

WARNING: multiple messages have this Message-ID
From: Corey Minyard <minyard@acm.org>
To: Richard Henderson <rth@redhat.com>
Cc: gcc@gcc.gnu.org
Subject: Re: Loop optimization bug with Ada front end on PPC (and probably Alpha)
Date: Tue, 27 Nov 2001 15:04:00 -0000	[thread overview]
Message-ID: <3C041C3F.3030508@acm.org> (raw)
Message-ID: <20011127150400.SNhMIhobuw1MEv7Sa0G6J0iTq5mCfB8W7zAuu2Ber_E@z> (raw)
In-Reply-To: <20011127142713.A30195@redhat.com>

Richard Henderson wrote:

  On Tue, Nov 27, 2001 at 03:26:43PM -0600, Corey Minyard wrote:
  
    Are you moving back to the original loop test?  I think the original test you had didn't work because it wasn't the doloop case, but if you put it in the doloop code it should work properly.
    
    I'm taking out the CONT test, yes.  But I'm keeping the LUID test against the BIV initializer rather than scanning with reg_set_between_p.
    
You will need to set the bl variable a little differently, in case its a
GIV.  I've attached a patch.  That was the cause of my segv earlier.  Bootstrapping
again....
    
-Corey
    
    
    
    
Index: doloop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doloop.c,v
retrieving revision 1.12
diff -u -p -r1.12 doloop.c
--- doloop.c	2001/11/16 02:26:38	1.12
+++ doloop.c	2001/11/27 23:01:46
@@ -596,6 +596,59 @@ doloop_modify_runtime (loop, iterations_
 			      copy_rtx (neg_inc ? final_value : initial_value),
 			      NULL_RTX, unsigned_p, OPTAB_LIB_WIDEN);
 
+  /* Some code transformations can result in code akin to
+
+	  tmp = i + 1;
+	  ...
+	  goto scan_start;
+	top:
+	  tmp = tmp + 1;
+	scan_start:
+	  i = tmp;
+	  if (i < n) goto top;
+
+     We'll have already detected this form of loop in scan_loop,
+     and set loop->top and loop->scan_start appropriately.
+
+     In this situation, we skip the increment the first time through
+     the loop, which results in an incorrect estimate of the number
+     of iterations.  Adjust the difference to compensate.  */
+  /* ??? Logically, it would seem this belongs in loop_iterations.
+     However, this causes regressions e.g. on x86 execute/20011008-3.c,
+     so I do not believe we've properly characterized the exact nature
+     of the problem.  In the meantime, this fixes execute/20011126-2.c
+     on ia64 and some Ada front end miscompilation on ppc.  */
+
+  if (loop->scan_start)
+    {
+      rtx iteration_var;
+      struct loop_ivs *ivs = LOOP_IVS (loop);
+      struct iv_class *bl;
+
+      iteration_var = loop_info->iteration_var;
+
+      if (REG_IV_TYPE (ivs, REGNO (iteration_var)) == BASIC_INDUCT)
+	bl = REG_IV_CLASS (ivs, REGNO (iteration_var));
+      else if (REG_IV_TYPE (ivs, REGNO (iteration_var)) == GENERAL_INDUCT)
+	{
+	  struct induction *v = REG_IV_INFO (ivs, REGNO (iteration_var));
+	  bl = REG_IV_CLASS (ivs, REGNO (v->src_reg));
+	}
+      else
+	abort(); /* iteration var must be an induction variable to get
+		    to here. */
+
+      if (INSN_LUID (bl->biv->insn) < INSN_LUID (loop->scan_start))
+	{
+	  if (loop_dump_stream)
+	    fprintf (loop_dump_stream,
+	         "Doloop: Basic induction var skips initial incr.\n");
+
+	  diff = expand_simple_binop (mode, PLUS, diff, increment, diff,
+				      unsigned_p, OPTAB_LIB_WIDEN);
+	}
+    }
+
   if (abs_inc * loop_info->unroll_number != 1)
     {
       int shift_count;

  reply	other threads:[~2001-11-27 23:04 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-13  5:20 Corey Minyard
2001-11-13  6:05 ` David Edelsohn
2001-11-14  8:05   ` Corey Minyard
2001-11-13  8:02 ` guerby
2001-11-13  9:48   ` Corey Minyard
2001-11-16 22:19     ` David Edelsohn
2001-11-26  7:39       ` David Edelsohn
2001-11-15  0:48 ` Richard Henderson
2001-11-15 14:19   ` Andreas Schwab
2001-11-15 16:20     ` Richard Henderson
2001-11-25 12:23       ` Richard Henderson
2001-11-18  9:18     ` Richard Henderson
2001-11-27  0:02       ` Richard Henderson
2001-11-25  8:57     ` Andreas Schwab
2001-11-15 18:02   ` Corey Minyard
2001-11-15 19:37     ` Richard Henderson
2001-11-25 15:52       ` Richard Henderson
2001-11-16  3:13     ` Richard Henderson
2001-11-16  3:42       ` Corey Minyard
2001-11-16  8:54         ` Bryce McKinlay
2001-11-26  0:47           ` Bryce McKinlay
2001-11-25 20:27         ` Corey Minyard
2001-11-17  1:33       ` Corey Minyard
2001-11-17  6:09         ` Corey Minyard
2001-11-26 10:22           ` Corey Minyard
2001-11-17 11:51         ` Richard Henderson
2001-11-17 15:20           ` Corey Minyard
2001-11-26 14:45             ` Corey Minyard
2001-11-18  5:15           ` Corey Minyard
2001-11-18  8:59             ` Richard Henderson
2001-11-19  2:58               ` Corey Minyard
2001-11-19  3:11                 ` Richard Henderson
2001-11-19  5:36                   ` Corey Minyard
2001-11-19  7:48                     ` Richard Henderson
2001-11-19  7:58                       ` Corey Minyard
2001-11-19  9:43                         ` Richard Henderson
2001-11-19 12:44                           ` Corey Minyard [this message]
2001-11-19 13:53                             ` Richard Henderson
2001-11-20 11:20                               ` Corey Minyard
2001-11-27 19:57                                 ` Corey Minyard
2001-11-27 15:31                               ` Richard Henderson
2001-11-27 15:04                             ` Corey Minyard
2001-11-27 14:27                           ` Richard Henderson
2001-11-27 13:25                         ` Corey Minyard
2001-11-27 12:58                       ` Richard Henderson
2001-11-27 11:51                     ` Corey Minyard
2001-11-27 10:29                   ` Richard Henderson
2001-11-27 10:08                 ` Corey Minyard
2001-11-26 23:18               ` Richard Henderson
2001-11-26 17:15             ` Corey Minyard
2001-11-26 13:49           ` Richard Henderson
2001-11-26  8:58         ` Corey Minyard
2001-11-25 17:58       ` Richard Henderson
2001-11-25 15:06     ` Corey Minyard
2001-11-15 18:47 Richard Kenner
2001-11-25 15:13 ` Richard Kenner
2001-11-15 19:05 dewar
2001-11-25 15:20 ` dewar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3C041C3F.3030508@acm.org \
    --to=minyard@acm.org \
    --cc=gcc@gcc.gnu.org \
    --cc=rth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).