Bug in tree-sra.c:sra_walk_modify_expr

Andrew Pinski pinskia@physics.uc.edu
Mon Nov 1 15:36:00 GMT 2004


On Nov 1, 2004, at 10:30 AM, Richard Kenner wrote:

> I think the "if (lhs_elt)" and "if (rhs_elt)" blocks have to be put in 
> the
> other order.  The way it is now is responsible for a group of 9 ACATS 
> tests
> that regressed a while ago.
>
> A tiny test case is
>
> PROCEDURE C41103A IS
>    TYPE R (LENGTH : INTEGER) IS
>       RECORD
> 	 S : STRING (1..LENGTH);
>       END RECORD;
>    N5 : R(4) := (LENGTH => 4, S => "ABCD");
> BEGIN
>      IF N5.S(3) /= 'C' THEN
> 	raise Program_Error;
>      END IF;
> END C41103A;
>
> The key statement is this one:
>
>   D.423 = VIEW_CONVERT_EXPR<struct c41103a__Tn5S>(D.422);
>
> D.423 and D.422.s are both done by element-copy.
>
> If the LHS is done first, that statement gets replaced by the four 
> copy-out
> statements for the replacements of D.423.  Then we call sra_walk_expr 
> and do
> the copy-in for D.422.s.  However, those are placed only before the 
> *last* of
> the copy-out statements, not before all of them, as they should be.

I get this on the current mainline.
Before SRA:
   character D.382;
   struct c41103a__Tn5S D.381;
   static struct c41103a__T4b C.0 = {.length=4, .s="ABCD"};
   struct c41103a__T4b D.379;

<bb 0>:
   D.379 = C.0;
   D.381 = VIEW_CONVERT_EXPR<struct c41103a__Tn5S>(D.379);
   n5 = D.381;
   D.382_8 = n5.s[3]{lb: 1 sz: 1};
   if (D.382_8 != 67) goto <L0>; else goto <L2>;

<L0>:;
   __gnat_rcheck_16 ("c41103a.adb", 9);

<L2>:;
   return;

After SRA:
   character D.382;
   struct c41103a__Tn5S D.381;
   static struct c41103a__T4b C.0 = {.length=4, .s="ABCD"};
   struct c41103a__T4b D.379;

<bb 0>:
   D.379 = C.0;
   SR.5_9 = VIEW_CONVERT_EXPR<struct c41103a__Tn5S>(D.379).s[4]{lb: 1 
sz: 1};
   SR.4_10 = VIEW_CONVERT_EXPR<struct c41103a__Tn5S>(D.379).s[3]{lb: 1 
sz: 1};
   SR.3_11 = VIEW_CONVERT_EXPR<struct c41103a__Tn5S>(D.379).s[2]{lb: 1 
sz: 1};
   SR.2_12 = VIEW_CONVERT_EXPR<struct c41103a__Tn5S>(D.379).s[1]{lb: 1 
sz: 1};
   SR.1_13 = VIEW_CONVERT_EXPR<struct c41103a__Tn5S>(D.379).length;
   n5$length_14 = SR.1_13;
   n5$s$4_15 = SR.5_9;
   n5$s$2_16 = SR.3_11;
   n5$s$1_17 = SR.2_12;
   n5$s$3_18 = SR.4_10;
   D.382_8 = n5$s$3_18;
   if (D.382_8 != 67) goto <L0>; else goto <L2>;

Which is correct.

Thanks,
Andrew Pinski



More information about the Gcc mailing list