[PATCH 9/9] cse.c selftests

Jeff Law law@redhat.com
Fri Sep 9 23:17:00 GMT 2016


On 09/09/2016 07:28 AM, Bernd Edlinger wrote:
> Hi David,
>
>> I attempted to create a reproducer for PR 71779; however I'm not yet
>> able to replicate the bogus cse reported there via the test case.
>
> Thanks, this is just awesome.  I immediately had to try your patch.
I'd pointed David at 71779 because it was such a good example of the 
kind of thing we'd like to be able to avoid by using the self-testing 
framework.

ie, someone says "hey, I don't think this code is needed anymore, let's 
remove it" and hope nothing breaks.  We do have the regression suite now 
which helps considerably, but changes early in the optimization pipeline 
may easily mask problems introduced much later in the pipeline.

With David's work, the goal is to be able to hand off reasonable hunks 
of RTL to internal routines and see how they manipulate the RTL and 
verify correctness.  Essentially bypassing everything except the 
routines in question that we want to test.

There's a lot of unknowns in this space and I'm hoping that David's work 
will shed some light on how we can build a robust RTL test framework.


>
> The main reason for PR 71779 was that this
>
> (insn 1047 1046 1048 (set (reg:DI 481)
>         (subreg:DI (reg/f:SI 479) 0)) y.c:12702 -1
>      (nil))
>
> got transformed into that:
>
> (insn 1047 1046 1048 107 (set (reg/f:DI 481)
>         (subreg:DI (reg/f:SI 477) 0)) y.c:12702 50 {*movdi_aarch64}
>      (expr_list:REG_DEAD (reg/f:SI 479)
>         (nil)))
>
> Note the "/f at reg 481.  This together with the fact that -mabi=ilp32
> makes Pmode != ptr_mode caused a cascade of different errors.
>
> For the wrong transformation in combine to happen, we need
> Pmode = DImode, ptr_mode=SImode, and REG_POINTER(x)
> is true, but only REG_POINTER is really wrong.
>
> First the good news.  The unit test does actually work, but not only
> on aarch even without -mabi=ilp32, but also on i386.  All that's
> missing is a check that we don't get a reg/f here:
Sweet.  This starts to touch on some of those unanswered questions -- 
while 71779 was visibly only failing on aarch64, can we build tests 
which are ultimately target independent?  I suspected that would be the 
case for 71779, but whether or not that will hold in general remains to 
be seen.


>
> test_pr71779 ()
> {
>   /* Only run this tests for target==aarch64.  */
> #ifndef GCC_AARCH64_H
> #ifndef I386_OPTS_H
>   return;
> #endif
> #endif
>   ...
>   tem = cse_main (get_insns (), max_reg_num ());
>   ASSERT_EQ (0, tem);
>   ASSERT_FALSE (REG_POINTER (SET_DEST (PATTERN (get_insn_by_uid (1047)))));
> }
>

>
> One minor thing, an unrelated test did fail before the cse test got executed on my aarch64,
> so I just commented that part out:
>
>
> /home/ed/gnu/gcc-build-aarch64/./gcc/xgcc -B/home/ed/gnu/gcc-build-aarch64/./gcc/ -xc -S -c /dev/null -fself-test
> ../../gcc-trunk/gcc/read-rtl-function.c:923: test_loading_dump_fragment_2: FAIL: ASSERT_TRUE ((((lhs)->frame_related)))
> In function 'test_1':
> cc1: internal compiler error: in fail, at selftest.c:46
> 0x11be8ae selftest::fail(selftest::location const&, char const*)
> 	../../gcc-trunk/gcc/selftest.c:46
> 0x115577a test_loading_dump_fragment_2
> 	../../gcc-trunk/gcc/read-rtl-function.c:923
> 0x1157cce selftest::read_rtl_function_c_tests()
> 	../../gcc-trunk/gcc/read-rtl-function.c:1183
> 0x1163d14 selftest::run_tests()
> 	../../gcc-trunk/gcc/selftest-run-tests.c:66
> 0xb36262 toplev::run_self_tests()
> 	../../gcc-trunk/gcc/toplev.c:2074
>
>
> the aarch64 was configured this way:
>
> ../gcc-trunk/configure --prefix=/home/ed/gnu/aarch64-unknown-elf --target=aarch64-unknown-elf --enable-languages=c --disable-shared --disable-threads --disable-libssp --disable-libgomp --disable-libquadmath --disable-libatomic
>
>
> Maybe one last comment on your patch itself, could you please move
> the unit test cases in extra unit test files, or even a self-test tree?
That's one of the things we debated for quite a while earlier.  For now 
they're living in the source files which they're testing.  Whether or 
not that's best remains to be seen.

jeff



More information about the Gcc-patches mailing list