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]

Re: Biv detection take 2


Jan

This patch has bug if seq is a zero length SEQUNCE. The problem is 
the following

	 last = XVECEXP (seq, 0, i - 1);

If seq is a zero length SEQUENCE then the above is accessing element
-1 (i.e. i is 0) which is wrong. I believe a zero length SEQUENCE is
possible if no insns are emitted between the calls to start_sequence()
and gen_sequence().

graham

Jan Hubicka wrote:
> 
> Hi
 cut
>     /* It is entirely possible that the expansion created lots of new
>        registers.  Iterate over the sequence we just created and
> *************** emit_iv_add_mult (b, m, a, reg, insert_b
> *** 8102,8115 ****
>         int i;
>         for (i = 0; i < XVECLEN (seq, 0); ++i)
>         {
> !         rtx set = single_set (XVECEXP (seq, 0, i));
>           if (set && GET_CODE (SET_DEST (set)) == REG)
>             record_base_value (REGNO (SET_DEST (set)), SET_SRC (set), 0);
>         }
>       }
> !   else if (GET_CODE (seq) == SET
> !          && GET_CODE (SET_DEST (seq)) == REG)
> !     record_base_value (REGNO (SET_DEST (seq)), SET_SRC (seq), 0);
>   }
> 
>   /* Test whether A * B can be computed without
> --- 8023,8069 ----
>         int i;
>         for (i = 0; i < XVECLEN (seq, 0); ++i)
>         {
> !         set = single_set (XVECEXP (seq, 0, i));
>           if (set && GET_CODE (SET_DEST (set)) == REG)
>             record_base_value (REGNO (SET_DEST (set)), SET_SRC (set), 0);
>         }
> +       last = XVECEXP (seq, 0, i - 1);
>       }
> !   else
> !     {
> cut

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