From: Sanjay M Pujare <sanjayp@eecg.toronto.edu>
Date: 	Wed, 23 Nov 1994 18:16:00 -0500
Subject: How to get induction variable elimination ?
Message-Id: <94Nov23.181605est.18962@picton.eecg.toronto.edu>



Hi,

  I have recently started using SUIF for my project. I would like to know if
any of the existing SUIF passes (porky or oynk) handle the following 
optimization :


  I would like to get induction variable elimination in all loops, for example
in a case as follows :


       int i, a[20];

       i = 0;
       while (i < 20) {
         a[i] = 2;
         ++i;
       }

In this case, I wanted 'i' to be eliminated (basic induction var. elimination)
and the loop test replaced with the induction variable related to address
calculation of a[i]. For example the compiler must be using a temp variable
(say t1) to calculate the offset of a[i] in a[] as :

      t1 = 4 * i;  /* assume sizeof(int) = 4 */
   
  So a[i] can be accessed as the int at address (&a + t1). With induction
variable detection, strength reduction, basic induction variable elimination
and loop test replacement (as described in the Dragon Book sec 10.7), I should
be able to get something like this :

       t1 = 0;
       while (t1 < 80) {
         *(int *)((void *)a + t1) = 2;
         t1 = t1 + 4;
       }

However I was unable to get this kind of optimization using SUIF. Can someone 
tell me if SUIF does this at all and which pass would do it and what options
to use?


Thanks in advance,

Sanjay (sanjayp@eecg.toronto.edu)