* [PATCH] i386: Fix wrong result for AMX-TILE intrinsic when parsing expression. @ 2021-11-04 1:18 Hongyu Wang 2021-11-04 2:24 ` Hongtao Liu 0 siblings, 1 reply; 4+ messages in thread From: Hongyu Wang @ 2021-11-04 1:18 UTC (permalink / raw) To: hongtao.liu; +Cc: gcc-patches Hi, _tile_loadd, _tile_stored, _tile_streamloadd intrinsics are defined by macro, so the parameters should be wrapped by parentheses to accept expressions. Bootstraped/regtested on x86_64-pc-linux-gnu{-m32,} and sde. OK for master and backport to GCC11 branch? gcc/ChangeLog: * config/i386/amxtileintrin.h (_tile_loadd_internal): Add parentheses to base and stride. (_tile_stream_loadd_internal): Likewise. (_tile_stored_internal): Likewise. --- gcc/config/i386/amxtileintrin.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/config/i386/amxtileintrin.h b/gcc/config/i386/amxtileintrin.h index 75d784ad160..3a0a6b44c17 100644 --- a/gcc/config/i386/amxtileintrin.h +++ b/gcc/config/i386/amxtileintrin.h @@ -62,7 +62,7 @@ _tile_release (void) #define _tile_loadd_internal(dst,base,stride) \ __asm__ volatile \ ("{tileloadd\t(%0,%1,1), %%tmm"#dst"|tileloadd\t%%tmm"#dst", [%0+%1*1]}" \ - :: "r" ((const void*) base), "r" ((long) stride)) + :: "r" ((const void*) (base)), "r" ((long) (stride))) #define _tile_stream_loadd(dst,base,stride) \ _tile_stream_loadd_internal (dst, base, stride) @@ -70,7 +70,7 @@ _tile_release (void) #define _tile_stream_loadd_internal(dst,base,stride) \ __asm__ volatile \ ("{tileloaddt1\t(%0,%1,1), %%tmm"#dst"|tileloaddt1\t%%tmm"#dst", [%0+%1*1]}" \ - :: "r" ((const void*) base), "r" ((long) stride)) + :: "r" ((const void*) (base)), "r" ((long) (stride))) #define _tile_stored(dst,base,stride) \ _tile_stored_internal (dst, base, stride) @@ -78,7 +78,7 @@ _tile_release (void) #define _tile_stored_internal(src,base,stride) \ __asm__ volatile \ ("{tilestored\t%%tmm"#src", (%0,%1,1)|tilestored\t[%0+%1*1], %%tmm"#src"}" \ - :: "r" ((void*) base), "r" ((long) stride) \ + :: "r" ((void*) (base)), "r" ((long) (stride)) \ : "memory") #define _tile_zero(dst) \ -- 2.18.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i386: Fix wrong result for AMX-TILE intrinsic when parsing expression. 2021-11-04 1:18 [PATCH] i386: Fix wrong result for AMX-TILE intrinsic when parsing expression Hongyu Wang @ 2021-11-04 2:24 ` Hongtao Liu 2021-11-04 3:25 ` Hongyu Wang 0 siblings, 1 reply; 4+ messages in thread From: Hongtao Liu @ 2021-11-04 2:24 UTC (permalink / raw) To: Hongyu Wang; +Cc: Liu, Hongtao, gcc-patches On Thu, Nov 4, 2021 at 9:19 AM Hongyu Wang via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > Hi, > > _tile_loadd, _tile_stored, _tile_streamloadd intrinsics are defined by > macro, so the parameters should be wrapped by parentheses to accept > expressions. > > Bootstraped/regtested on x86_64-pc-linux-gnu{-m32,} and sde. > > OK for master and backport to GCC11 branch? Could you add a testcase for that? > > gcc/ChangeLog: > > * config/i386/amxtileintrin.h (_tile_loadd_internal): Add > parentheses to base and stride. > (_tile_stream_loadd_internal): Likewise. > (_tile_stored_internal): Likewise. > --- > gcc/config/i386/amxtileintrin.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/gcc/config/i386/amxtileintrin.h b/gcc/config/i386/amxtileintrin.h > index 75d784ad160..3a0a6b44c17 100644 > --- a/gcc/config/i386/amxtileintrin.h > +++ b/gcc/config/i386/amxtileintrin.h > @@ -62,7 +62,7 @@ _tile_release (void) > #define _tile_loadd_internal(dst,base,stride) \ > __asm__ volatile \ > ("{tileloadd\t(%0,%1,1), %%tmm"#dst"|tileloadd\t%%tmm"#dst", [%0+%1*1]}" \ > - :: "r" ((const void*) base), "r" ((long) stride)) > + :: "r" ((const void*) (base)), "r" ((long) (stride))) > > #define _tile_stream_loadd(dst,base,stride) \ > _tile_stream_loadd_internal (dst, base, stride) > @@ -70,7 +70,7 @@ _tile_release (void) > #define _tile_stream_loadd_internal(dst,base,stride) \ > __asm__ volatile \ > ("{tileloaddt1\t(%0,%1,1), %%tmm"#dst"|tileloaddt1\t%%tmm"#dst", [%0+%1*1]}" \ > - :: "r" ((const void*) base), "r" ((long) stride)) > + :: "r" ((const void*) (base)), "r" ((long) (stride))) > > #define _tile_stored(dst,base,stride) \ > _tile_stored_internal (dst, base, stride) > @@ -78,7 +78,7 @@ _tile_release (void) > #define _tile_stored_internal(src,base,stride) \ > __asm__ volatile \ > ("{tilestored\t%%tmm"#src", (%0,%1,1)|tilestored\t[%0+%1*1], %%tmm"#src"}" \ > - :: "r" ((void*) base), "r" ((long) stride) \ > + :: "r" ((void*) (base)), "r" ((long) (stride)) \ > : "memory") > > #define _tile_zero(dst) \ > -- > 2.18.1 > -- BR, Hongtao ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i386: Fix wrong result for AMX-TILE intrinsic when parsing expression. 2021-11-04 2:24 ` Hongtao Liu @ 2021-11-04 3:25 ` Hongyu Wang 2021-11-04 4:46 ` Hongtao Liu 0 siblings, 1 reply; 4+ messages in thread From: Hongyu Wang @ 2021-11-04 3:25 UTC (permalink / raw) To: Hongtao Liu; +Cc: Hongyu Wang, Liu, Hongtao, gcc-patches [-- Attachment #1: Type: text/plain, Size: 2788 bytes --] > Could you add a testcase for that? Yes, updated patch. Hongtao Liu via Gcc-patches <gcc-patches@gcc.gnu.org> 于2021年11月4日周四 上午10:25写道: > > On Thu, Nov 4, 2021 at 9:19 AM Hongyu Wang via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > Hi, > > > > _tile_loadd, _tile_stored, _tile_streamloadd intrinsics are defined by > > macro, so the parameters should be wrapped by parentheses to accept > > expressions. > > > > Bootstraped/regtested on x86_64-pc-linux-gnu{-m32,} and sde. > > > > OK for master and backport to GCC11 branch? > Could you add a testcase for that? > > > > gcc/ChangeLog: > > > > * config/i386/amxtileintrin.h (_tile_loadd_internal): Add > > parentheses to base and stride. > > (_tile_stream_loadd_internal): Likewise. > > (_tile_stored_internal): Likewise. > > --- > > gcc/config/i386/amxtileintrin.h | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/gcc/config/i386/amxtileintrin.h b/gcc/config/i386/amxtileintrin.h > > index 75d784ad160..3a0a6b44c17 100644 > > --- a/gcc/config/i386/amxtileintrin.h > > +++ b/gcc/config/i386/amxtileintrin.h > > @@ -62,7 +62,7 @@ _tile_release (void) > > #define _tile_loadd_internal(dst,base,stride) \ > > __asm__ volatile \ > > ("{tileloadd\t(%0,%1,1), %%tmm"#dst"|tileloadd\t%%tmm"#dst", [%0+%1*1]}" \ > > - :: "r" ((const void*) base), "r" ((long) stride)) > > + :: "r" ((const void*) (base)), "r" ((long) (stride))) > > > > #define _tile_stream_loadd(dst,base,stride) \ > > _tile_stream_loadd_internal (dst, base, stride) > > @@ -70,7 +70,7 @@ _tile_release (void) > > #define _tile_stream_loadd_internal(dst,base,stride) \ > > __asm__ volatile \ > > ("{tileloaddt1\t(%0,%1,1), %%tmm"#dst"|tileloaddt1\t%%tmm"#dst", [%0+%1*1]}" \ > > - :: "r" ((const void*) base), "r" ((long) stride)) > > + :: "r" ((const void*) (base)), "r" ((long) (stride))) > > > > #define _tile_stored(dst,base,stride) \ > > _tile_stored_internal (dst, base, stride) > > @@ -78,7 +78,7 @@ _tile_release (void) > > #define _tile_stored_internal(src,base,stride) \ > > __asm__ volatile \ > > ("{tilestored\t%%tmm"#src", (%0,%1,1)|tilestored\t[%0+%1*1], %%tmm"#src"}" \ > > - :: "r" ((void*) base), "r" ((long) stride) \ > > + :: "r" ((void*) (base)), "r" ((long) (stride)) \ > > : "memory") > > > > #define _tile_zero(dst) \ > > -- > > 2.18.1 > > > > > -- > BR, > Hongtao [-- Attachment #2: 0001-i386-Fix-wrong-result-for-AMX-TILE-intrinsic-when-pa.patch --] [-- Type: application/octet-stream, Size: 3634 bytes --] From 78f3d669fa6d67719c9e044e4cc581c77c7326da Mon Sep 17 00:00:00 2001 From: Hongyu Wang <hongyu.wang@intel.com> Date: Wed, 3 Nov 2021 13:58:52 +0800 Subject: [PATCH] i386: Fix wrong result for AMX-TILE intrinsic when parsing expression. _tile_loadd, _tile_stored, _tile_streamloadd intrinsics are defined by macro, so the parameters should be wrapped by parentheses to accept expressions. gcc/ChangeLog: * config/i386/amxtileintrin.h (_tile_loadd_internal): Add parentheses to base and stride. (_tile_stream_loadd_internal): Likewise. (_tile_stored_internal): Likewise. gcc/testsuite/ChangeLog: * gcc.target/i386/amxtile-3.c: New test. --- gcc/config/i386/amxtileintrin.h | 6 ++--- gcc/testsuite/gcc.target/i386/amxtile-3.c | 28 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/amxtile-3.c diff --git a/gcc/config/i386/amxtileintrin.h b/gcc/config/i386/amxtileintrin.h index 75d784ad160..3a0a6b44c17 100644 --- a/gcc/config/i386/amxtileintrin.h +++ b/gcc/config/i386/amxtileintrin.h @@ -62,7 +62,7 @@ _tile_release (void) #define _tile_loadd_internal(dst,base,stride) \ __asm__ volatile \ ("{tileloadd\t(%0,%1,1), %%tmm"#dst"|tileloadd\t%%tmm"#dst", [%0+%1*1]}" \ - :: "r" ((const void*) base), "r" ((long) stride)) + :: "r" ((const void*) (base)), "r" ((long) (stride))) #define _tile_stream_loadd(dst,base,stride) \ _tile_stream_loadd_internal (dst, base, stride) @@ -70,7 +70,7 @@ _tile_release (void) #define _tile_stream_loadd_internal(dst,base,stride) \ __asm__ volatile \ ("{tileloaddt1\t(%0,%1,1), %%tmm"#dst"|tileloaddt1\t%%tmm"#dst", [%0+%1*1]}" \ - :: "r" ((const void*) base), "r" ((long) stride)) + :: "r" ((const void*) (base)), "r" ((long) (stride))) #define _tile_stored(dst,base,stride) \ _tile_stored_internal (dst, base, stride) @@ -78,7 +78,7 @@ _tile_release (void) #define _tile_stored_internal(src,base,stride) \ __asm__ volatile \ ("{tilestored\t%%tmm"#src", (%0,%1,1)|tilestored\t[%0+%1*1], %%tmm"#src"}" \ - :: "r" ((void*) base), "r" ((long) stride) \ + :: "r" ((void*) (base)), "r" ((long) (stride)) \ : "memory") #define _tile_zero(dst) \ diff --git a/gcc/testsuite/gcc.target/i386/amxtile-3.c b/gcc/testsuite/gcc.target/i386/amxtile-3.c new file mode 100644 index 00000000000..31b34d0ed15 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/amxtile-3.c @@ -0,0 +1,28 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mamx-tile " } */ +/* { dg-final { scan-assembler "tileloadd\[ \\t]+\[^\n\]*\\(%\[a-z0-9]*\,%\[a-z0-9\]*\,\[124\]\\)+\[^\n\]*%tmm\[0-9\]" } } */ +/* { dg-final { scan-assembler "tileloaddt1\[ \\t]+\[^\n\]*\\(%\[a-z0-9]*\,%\[a-z0-9\]*\,\[124\]\\)+\[^\n\]*%tmm\[0-9\]" } } */ +/* { dg-final { scan-assembler "tilestored\[ \\t]+\[^\n\]*%tmm\[0-9\]+\[^\n\]*\\(%\[a-z0-9]*\,%\[a-z0-9\]*\,\[124\]\\)" } } */ +/* { dg-final { scan-assembler "leaq\[ \\t]+4" } } */ +/* { dg-final { scan-assembler "leaq\[ \\t]+8" } } */ +/* { dg-final { scan-assembler "addq\[ \\t]+\\\$12" } } */ +/* { dg-final { scan-assembler-not "leaq\[ \\t]+1" } } */ +/* { dg-final { scan-assembler-not "leaq\[ \\t]+2" } } */ +/* { dg-final { scan-assembler-not "addq\[ \\t]+\\\$3" } } */ +#include <immintrin.h> + +extern int a[]; +extern const float* base; +extern const int stride; + +#define TMM0 0 +#define TMM1 1 +#define TMM2 2 +#define TMM3 3 + +void TEST () +{ + _tile_loadd (TMM3, base + 1, stride); + _tile_stream_loadd (TMM2, base + 2, stride); + _tile_stored (TMM2, base + 3, stride); +} -- 2.18.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i386: Fix wrong result for AMX-TILE intrinsic when parsing expression. 2021-11-04 3:25 ` Hongyu Wang @ 2021-11-04 4:46 ` Hongtao Liu 0 siblings, 0 replies; 4+ messages in thread From: Hongtao Liu @ 2021-11-04 4:46 UTC (permalink / raw) To: Hongyu Wang; +Cc: Hongyu Wang, Liu, Hongtao, GCC Patches On Thu, Nov 4, 2021 at 11:25 AM Hongyu Wang <wwwhhhyyy333@gmail.com> wrote: > > > Could you add a testcase for that? > > Yes, updated patch. > > Hongtao Liu via Gcc-patches <gcc-patches@gcc.gnu.org> 于2021年11月4日周四 上午10:25写道: > > > > On Thu, Nov 4, 2021 at 9:19 AM Hongyu Wang via Gcc-patches > > <gcc-patches@gcc.gnu.org> wrote: > > > > > > Hi, > > > > > > _tile_loadd, _tile_stored, _tile_streamloadd intrinsics are defined by > > > macro, so the parameters should be wrapped by parentheses to accept > > > expressions. > > > > > > Bootstraped/regtested on x86_64-pc-linux-gnu{-m32,} and sde. > > > > > > OK for master and backport to GCC11 branch? LGTM. > > Could you add a testcase for that? > > > > > > gcc/ChangeLog: > > > > > > * config/i386/amxtileintrin.h (_tile_loadd_internal): Add > > > parentheses to base and stride. > > > (_tile_stream_loadd_internal): Likewise. > > > (_tile_stored_internal): Likewise. > > > --- > > > gcc/config/i386/amxtileintrin.h | 6 +++--- > > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > > > diff --git a/gcc/config/i386/amxtileintrin.h b/gcc/config/i386/amxtileintrin.h > > > index 75d784ad160..3a0a6b44c17 100644 > > > --- a/gcc/config/i386/amxtileintrin.h > > > +++ b/gcc/config/i386/amxtileintrin.h > > > @@ -62,7 +62,7 @@ _tile_release (void) > > > #define _tile_loadd_internal(dst,base,stride) \ > > > __asm__ volatile \ > > > ("{tileloadd\t(%0,%1,1), %%tmm"#dst"|tileloadd\t%%tmm"#dst", [%0+%1*1]}" \ > > > - :: "r" ((const void*) base), "r" ((long) stride)) > > > + :: "r" ((const void*) (base)), "r" ((long) (stride))) > > > > > > #define _tile_stream_loadd(dst,base,stride) \ > > > _tile_stream_loadd_internal (dst, base, stride) > > > @@ -70,7 +70,7 @@ _tile_release (void) > > > #define _tile_stream_loadd_internal(dst,base,stride) \ > > > __asm__ volatile \ > > > ("{tileloaddt1\t(%0,%1,1), %%tmm"#dst"|tileloaddt1\t%%tmm"#dst", [%0+%1*1]}" \ > > > - :: "r" ((const void*) base), "r" ((long) stride)) > > > + :: "r" ((const void*) (base)), "r" ((long) (stride))) > > > > > > #define _tile_stored(dst,base,stride) \ > > > _tile_stored_internal (dst, base, stride) > > > @@ -78,7 +78,7 @@ _tile_release (void) > > > #define _tile_stored_internal(src,base,stride) \ > > > __asm__ volatile \ > > > ("{tilestored\t%%tmm"#src", (%0,%1,1)|tilestored\t[%0+%1*1], %%tmm"#src"}" \ > > > - :: "r" ((void*) base), "r" ((long) stride) \ > > > + :: "r" ((void*) (base)), "r" ((long) (stride)) \ > > > : "memory") > > > > > > #define _tile_zero(dst) \ > > > -- > > > 2.18.1 > > > > > > > > > -- > > BR, > > Hongtao -- BR, Hongtao ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-11-04 4:39 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-11-04 1:18 [PATCH] i386: Fix wrong result for AMX-TILE intrinsic when parsing expression Hongyu Wang 2021-11-04 2:24 ` Hongtao Liu 2021-11-04 3:25 ` Hongyu Wang 2021-11-04 4:46 ` Hongtao Liu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).