On April 10, 2021 8:07:57 AM GMT+02:00, Jakub Jelinek <ja...@redhat.com> wrote: >Hi! > >This is a sequel to the PR85022 changes, inline-asm can (unfortunately) >introduce VOIDmode MEMs and in PR85022 they have been changed so that >we don't pretend we know their size (as opposed to assuming they have >zero size). > >This time we ICE in rtx_addr_can_trap_p_1 because it assumes that >all memory but BLKmode has known size. The patch just treats VOIDmode >MEMs like BLKmode in that regard. And, the STRICT_ALIGNMENT change >is needed because VOIDmode has GET_MODE_SIZE of 0 and we don't want to >check if something is a multiple of 0. > >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Ok. We can experiment with differnt canonicalization in GCC 12. Richard. >2021-04-10 Jakub Jelinek <ja...@redhat.com> > > PR rtl-optimization/98601 > * rtlanal.c (rtx_addr_can_trap_p_1): Allow in assert unknown size > not just for BLKmode, but also for VOIDmode. For STRICT_ALIGNMENT > unaligned_mems handle VOIDmode like BLKmode. > > * gcc.dg/torture/pr98601.c: New test. > >--- gcc/rtlanal.c.jj 2021-03-05 21:51:48.689185518 +0100 >+++ gcc/rtlanal.c 2021-04-09 11:15:20.341906331 +0200 >@@ -464,12 +464,17 @@ rtx_addr_can_trap_p_1 (const_rtx x, poly > machine_mode mode, bool unaligned_mems) > { > enum rtx_code code = GET_CODE (x); >- gcc_checking_assert (mode == BLKmode || known_size_p (size)); >+ gcc_checking_assert (mode == BLKmode >+ || mode == VOIDmode >+ || known_size_p (size)); > poly_int64 const_x1; > >/* The offset must be a multiple of the mode size if we are considering > unaligned memory references on strict alignment machines. */ >- if (STRICT_ALIGNMENT && unaligned_mems && mode != BLKmode) >+ if (STRICT_ALIGNMENT >+ && unaligned_mems >+ && mode != BLKmode >+ && mode != VOIDmode) > { > poly_int64 actual_offset = offset; > >--- gcc/testsuite/gcc.dg/torture/pr98601.c.jj 2021-04-09 >11:18:26.964817854 +0200 >+++ gcc/testsuite/gcc.dg/torture/pr98601.c 2021-04-09 >11:18:16.758932053 +0200 >@@ -0,0 +1,14 @@ >+/* PR rtl-optimization/98601 */ >+/* { dg-do compile } */ >+ >+void >+foo (void *p) >+{ >+ asm ("" : "=m" (*p)); /* { dg-warning "dereferencing >'void \\*' >pointer" } */ >+} >+ >+void >+bar (void *p) >+{ >+ asm volatile ("" : : "m" (*p)); /* { dg-warning "dereferencing 'void >\\*' pointer" } */ >+} > > Jakub