> I tried to translate the c-test case to an equivalent ada test case with
> my not-so-fluent Ada speak...
>
> So here is a test case that *actually* hits the if ((boff % BITS_PER_UNIT)
> != 0) code path.
I see, well done then.
> Before my patch there was an unaligned SImode access, and with
> the patch we have 3 QImode accesses here.
>
> cat pr71083_pkg.ads
> package Pr71083_pkg is
> type Nibble is mod 2**4;
> type Int24 is mod 2**24;
> type StructA is record
> a : Nibble;
> b : Int24;
> end record;
> pragma Pack(StructA);
> type StructB is record
> a : Nibble;
> b : StructA;
> end record;
> pragma Pack(StructB);
> type ArrayOfStructB is array(0..100) of StructB;
> procedure Foo (X : in out ArrayOfStructB);
> end Pr71083_pkg;
>
> cat pr71083_pkg.adb
> -- { dg-do compile }
> -- { dg-options "-O3" }
> package body Pr71083_pkg is
> procedure Foo (X : in out ArrayOfStructB) is
> begin
> for K in 0..99 loop
> X (K+1).b.b := X (K).b.b;
> end loop;
> end Foo;
> end Pr71083_pkg;
>
> cat pr71083.adb
> -- { dg-do run }
> -- { dg-options "-O3" }
> with Pr71083_pkg;
> use Pr71083_pkg;
> procedure Pr71083 is
> Test : ArrayOfStructB;
> begin
> Test (0).b.b := 9999;
> Foo (Test);
> if Test (100).b.b /= 9999 then
> raise Program_Error;
> end if;
> end;
>
>
> I was not sure which name to choose,
> so I used the same convention as in the c-torture.
> How do you like that?
Worst convention ever. :-) Either opt57 or loop_optimization23 at your
convenience (you can add a reference to the PR in a comment).
> I would like to add that to the gnat.dg because
> it seems that there is zero testing for the predictive
> commoning in the gnat.dg test suite.
Very likely so. The renamed testcase is OK for mainline, but please replace
"Eric's" with "the" in the patch or copy-and-paste the explanation.
--
Eric Botcazou