Message ID | CAKdteOZNUkGTSW8Smk75Tm95e4BbGUChUMjHY2v6uB0n6tCFiA@mail.gmail.com |
---|---|
State | New |
Headers | show |
Series | [AArch64] Backport to gcc-7 PR71727 fix -mstrict-align | expand |
On 04/10/17 14:35, Christophe Lyon wrote: > Hi, > > I've recently committed a follow-up fix for PR71727 for -mstrict-align > on aarch64 (r253242). > I think it would be appropriate to apply it to gcc-7-branch. The patch > from trunk applies cleanly to gcc-7-branch. > > Although the original bug was reported against 4.9.4, 5.3.1, 6.1.0, > Naveen's patch was not backported to these branches, so it's not > appropriate to backport my patch there. > > OK? > > Thanks, > > Christophe > > > aarch64-strict-align3.chlog.txt > > > 2017-09-20 Christophe Lyon <christophe.lyon@linaro.org> > > PR target/71727 > gcc/ > * config/aarch64/aarch64.c > (aarch64_builtin_support_vector_misalignment): Always return false > when misalignment is unknown. > > gcc/testsuite/ > * gcc.target/aarch64/pr71727-2.c: New test. > OK. R. > > aarch64-strict-align3.patch.txt > > > diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c > index 799989a..7cc67ec 100644 > --- a/gcc/config/aarch64/aarch64.c > +++ b/gcc/config/aarch64/aarch64.c > @@ -11757,19 +11757,9 @@ aarch64_builtin_support_vector_misalignment (machine_mode mode, > if (optab_handler (movmisalign_optab, mode) == CODE_FOR_nothing) > return false; > > + /* Misalignment factor is unknown at compile time. */ > if (misalignment == -1) > - { > - /* Misalignment factor is unknown at compile time but we know > - it's word aligned. */ > - if (aarch64_simd_vector_alignment_reachable (type, is_packed)) > - { > - int element_size = TREE_INT_CST_LOW (TYPE_SIZE (type)); > - > - if (element_size != 64) > - return true; > - } > - return false; > - } > + return false; > } > return default_builtin_support_vector_misalignment (mode, type, misalignment, > is_packed); > diff --git a/gcc/testsuite/gcc.target/aarch64/pr71727-2.c b/gcc/testsuite/gcc.target/aarch64/pr71727-2.c > new file mode 100644 > index 0000000..2bc803a > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/pr71727-2.c > @@ -0,0 +1,16 @@ > +/* { dg-do compile } */ > +/* { dg-options "-mstrict-align -O3" } */ > + > +unsigned char foo(const unsigned char *buffer, unsigned int length) > +{ > + unsigned char sum; > + unsigned int count; > + > + for (sum = 0, count = 0; count < length; count++) { > + sum = (unsigned char) (sum + *(buffer + count)); > + } > + > + return sum; > +} > + > +/* { dg-final { scan-assembler-times "and\tw\[0-9\]+, w\[0-9\]+, 15" 1 } } */ >
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 799989a..7cc67ec 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -11757,19 +11757,9 @@ aarch64_builtin_support_vector_misalignment (machine_mode mode, if (optab_handler (movmisalign_optab, mode) == CODE_FOR_nothing) return false; + /* Misalignment factor is unknown at compile time. */ if (misalignment == -1) - { - /* Misalignment factor is unknown at compile time but we know - it's word aligned. */ - if (aarch64_simd_vector_alignment_reachable (type, is_packed)) - { - int element_size = TREE_INT_CST_LOW (TYPE_SIZE (type)); - - if (element_size != 64) - return true; - } - return false; - } + return false; } return default_builtin_support_vector_misalignment (mode, type, misalignment, is_packed); diff --git a/gcc/testsuite/gcc.target/aarch64/pr71727-2.c b/gcc/testsuite/gcc.target/aarch64/pr71727-2.c new file mode 100644 index 0000000..2bc803a --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr71727-2.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-mstrict-align -O3" } */ + +unsigned char foo(const unsigned char *buffer, unsigned int length) +{ + unsigned char sum; + unsigned int count; + + for (sum = 0, count = 0; count < length; count++) { + sum = (unsigned char) (sum + *(buffer + count)); + } + + return sum; +} + +/* { dg-final { scan-assembler-times "and\tw\[0-9\]+, w\[0-9\]+, 15" 1 } } */