[Bug target/113711] APX instruction set and instructions longer than 15 bytes (assembly warning)

2024-02-19 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113711

--- Comment #11 from GCC Commits  ---
The master branch has been updated by hongtao Liu :

https://gcc.gnu.org/g:5a9a9bd415ed1d211e00990226b90199407b3448

commit r14-9078-g5a9a9bd415ed1d211e00990226b90199407b3448
Author: liuhongt 
Date:   Mon Feb 19 12:19:35 2024 +0800

Fix testcase for platform without gnu/stubs-x32.h

target maybe_x32 doesn't check if platform has gnu/stubs-x32.h, but
it's included by stdint.h in the testcase.
Adjust testcase: remove stdint.h, use 'typedef long long int64_t'
instead.

gcc/testsuite/ChangeLog:

PR target/113711
* gcc.target/i386/apx-ndd-x32-1.c: Adjust testcase.

[Bug target/113711] APX instruction set and instructions longer than 15 bytes (assembly warning)

2024-02-08 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113711

--- Comment #10 from GCC Commits  ---
The master branch has been updated by H.J. Lu :

https://gcc.gnu.org/g:d2798598c4fcf2281921df3c2b7b1d16a171fa03

commit r14-8883-gd2798598c4fcf2281921df3c2b7b1d16a171fa03
Author: H.J. Lu 
Date:   Mon Feb 5 19:48:48 2024 -0800

x86: Update constraints for APX NDD instructions

1. The only supported TLS code sequence with ADD is

addq foo@gottpoff(%rip),%reg

Change je constraint to a memory operand in APX NDD ADD pattern with
register source operand.

2. The instruction length of APX NDD instructions with immediate operand:

op imm, mem, reg

may exceed the size limit of 15 byes when non-default address space,
segment register or address size prefix are used.

Add jM constraint which is a memory operand valid for APX NDD instructions
with immediate operand and add jO constraint which is an offsetable memory
operand valid for APX NDD instructions with immediate operand.  Update
APX NDD patterns with jM and jO constraints.

gcc/

PR target/113711
PR target/113733
* config/i386/constraints.md: List all constraints with j prefix.
(j>): Change auto-dec to auto-inc in documentation.
(je): Changed to a memory constraint with APX NDD TLS operand
check.
(jM): New memory constraint for APX NDD instructions.
(jO): Likewise.
* config/i386/i386-protos.h (x86_poff_operand_p): Removed.
* config/i386/i386.cc (x86_poff_operand_p): Likewise.
* config/i386/i386.md (*add3_doubleword): Use rjO.
(*add_1[SWI48]): Use je and jM.
(addsi_1_zext): Use jM.
(*addv4_doubleword_1[DWI]): Likewise.
(*sub_1[SWI]): Use jM.
(@add3_cc_overflow_1[SWI]): Likewise.
(*add3_doubleword_cc_overflow_1): Use rjO.
(*and3_doubleword): Likewise.
(*anddi_1): Use jM.
(*andsi_1_zext): Likewise.
(*and_1[SWI24]): Likewise.
(*3_doubleword[any_or]): Use rjO
(*code_1[any_or SWI248]): Use jM.
(*si_1_zext[zero_extend + any_or]): Likewise.
* config/i386/predicates.md (apx_ndd_memory_operand): New.
(apx_ndd_add_memory_operand): Likewise.

gcc/testsuite/

PR target/113711
PR target/113733
* gcc.target/i386/apx-ndd-2.c: New test.
* gcc.target/i386/apx-ndd-base-index-1.c: Likewise.
* gcc.target/i386/apx-ndd-no-seg-global-1.c: Likewise.
* gcc.target/i386/apx-ndd-seg-1.c: Likewise.
* gcc.target/i386/apx-ndd-seg-2.c: Likewise.
* gcc.target/i386/apx-ndd-seg-3.c: Likewise.
* gcc.target/i386/apx-ndd-seg-4.c: Likewise.
* gcc.target/i386/apx-ndd-seg-5.c: Likewise.
* gcc.target/i386/apx-ndd-tls-1a.c: Likewise.
* gcc.target/i386/apx-ndd-tls-2.c: Likewise.
* gcc.target/i386/apx-ndd-tls-3.c: Likewise.
* gcc.target/i386/apx-ndd-tls-4.c: Likewise.
* gcc.target/i386/apx-ndd-x32-1.c: Likewise.

[Bug target/113711] APX instruction set and instructions longer than 15 bytes (assembly warning)

2024-02-03 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113711

--- Comment #9 from H.J. Lu  ---
Many NDD patterns have the same issue.  Here is another testcase:

[hjl@gnu-cfl-3 pr113711]$ cat apx-ndd-length-X.c
/* { dg-do assemble { target { apxf && { ! ia32 } } } } */
/* { dg-options "-mapxf -O2" } */

typedef signed __int128 S;
int o;

S
qux (void)
{
  S z;
  o = __builtin_add_overflow (*(S __seg_fs *) 0x1000, 0x200, );
  return z;
}
[hjl@gnu-cfl-3 pr113711]$ make apx-ndd-length-X.o
/export/build/gnu/tools-build/gcc-gitlab-debug/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/tools-build/gcc-gitlab-debug/build-x86_64-linux/gcc/ -mapxf
-O3 -dp   -c -o apx-ndd-length-X.o apx-ndd-length-X.c
/tmp/cc1eMHh5.s: Assembler messages:
/tmp/cc1eMHh5.s:9: Warning: instruction length of 16 bytes exceeds the limit of
15
[hjl@gnu-cfl-3 pr113711]$ cat apx-ndd-length-Y.c 
/* { dg-do assemble { target { apxf && { ! ia32 } } } } */
/* { dg-options "-mapxf -O2" } */

__thread signed __int128 var;
int o;

signed __int128
qux (void)
{
  signed __int128 z;
  o = __builtin_add_overflow (var, 0x200, );
  return z;
}
[hjl@gnu-cfl-3 pr113711]$ make apx-ndd-length-Y.o
/export/build/gnu/tools-build/gcc-gitlab-debug/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/tools-build/gcc-gitlab-debug/build-x86_64-linux/gcc/ -mapxf
-O3 -dp   -c -o apx-ndd-length-Y.o apx-ndd-length-Y.c
/tmp/ccwvDbZA.s: Assembler messages:
/tmp/ccwvDbZA.s:9: Warning: instruction length of 16 bytes exceeds the limit of
15
[hjl@gnu-cfl-3 pr113711]$ 

We need to exam all NDD patterns to check invalid memory constraint.
We should find a testcase for each issue we find.

[Bug target/113711] APX instruction set and instructions longer than 15 bytes (assembly warning)

2024-02-02 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113711

--- Comment #8 from H.J. Lu  ---
My branch is at

https://gitlab.com/x86-gcc/gcc/-/commits/users/hjl/pr113711/master

We need to add more tests:

1. All NDD instructions are 15 bytes or less.
2. Use "op imm, mem, reg" whenever possible.

[Bug target/113711] APX instruction set and instructions longer than 15 bytes (assembly warning)

2024-02-02 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113711

--- Comment #7 from H.J. Lu  ---
(In reply to Hongyu Wang from comment #6)
> (In reply to H.J. Lu from comment #5)
> > (In reply to Hongyu Wang from comment #4)
> > > Previously I added 
> > > https://gcc.gnu.org/git/?p=gcc.git;a=commit;
> > > h=d564198f960a2f5994dde3f6b83d7a62021e49c3
> > > 
> > > to prohibit several *POFF constant usage in NDD add alternative. If 
> > > checking
> > > ADDR_SPACE_GENERIC can avoid the seg prefix usage, we can drop that 
> > > change?
> > 
> > Are there are any testcases for this change?
> > 
> 
> Cut and edit from gcc.dg\torture\tls\tls-test.c
> 
> #include 
> __thread int a = 255; 
> __thread int *b;
> int *volatile a_in_other_thread = (int *) 12345;
> 
> void *
> thread_func (void *arg)
> {
>   a_in_other_thread =  //Previously it will try to generate addq
> $a@tpoff, %fs:0, %rax 
>   a+=11144; //this was not fixed on trunk as UNSPEC_TPOFF is in mem operand
>   *((int *) arg) = a;
> 
>   return (void *)0;
> }

My patch seems to work.  But we need to add such tests to gcc.target/i386.

[Bug target/113711] APX instruction set and instructions longer than 15 bytes (assembly warning)

2024-02-02 Thread hongyuw at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113711

--- Comment #6 from Hongyu Wang  ---
(In reply to H.J. Lu from comment #5)
> (In reply to Hongyu Wang from comment #4)
> > Previously I added 
> > https://gcc.gnu.org/git/?p=gcc.git;a=commit;
> > h=d564198f960a2f5994dde3f6b83d7a62021e49c3
> > 
> > to prohibit several *POFF constant usage in NDD add alternative. If checking
> > ADDR_SPACE_GENERIC can avoid the seg prefix usage, we can drop that change?
> 
> Are there are any testcases for this change?
> 

Cut and edit from gcc.dg\torture\tls\tls-test.c

#include 
__thread int a = 255; 
__thread int *b;
int *volatile a_in_other_thread = (int *) 12345;

void *
thread_func (void *arg)
{
  a_in_other_thread =  //Previously it will try to generate addq $a@tpoff,
%fs:0, %rax 
  a+=11144; //this was not fixed on trunk as UNSPEC_TPOFF is in mem operand
  *((int *) arg) = a;

  return (void *)0;
}

[Bug target/113711] APX instruction set and instructions longer than 15 bytes (assembly warning)

2024-02-02 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113711

--- Comment #5 from H.J. Lu  ---
(In reply to Hongyu Wang from comment #4)
> Previously I added 
> https://gcc.gnu.org/git/?p=gcc.git;a=commit;
> h=d564198f960a2f5994dde3f6b83d7a62021e49c3
> 
> to prohibit several *POFF constant usage in NDD add alternative. If checking
> ADDR_SPACE_GENERIC can avoid the seg prefix usage, we can drop that change?

Are there are any testcases for this change?

> And I'd suggest to use j prefix for all APX related constraints like jf.

Will do.

[Bug target/113711] APX instruction set and instructions longer than 15 bytes (assembly warning)

2024-02-02 Thread hongyuw at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113711

--- Comment #4 from Hongyu Wang  ---
Previously I added 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d564198f960a2f5994dde3f6b83d7a62021e49c3

to prohibit several *POFF constant usage in NDD add alternative. If checking
ADDR_SPACE_GENERIC can avoid the seg prefix usage, we can drop that change?

And I'd suggest to use j prefix for all APX related constraints like jf.

[Bug target/113711] APX instruction set and instructions longer than 15 bytes (assembly warning)

2024-02-02 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113711

H.J. Lu  changed:

   What|Removed |Added

  Attachment #57288|0   |1
is obsolete||

--- Comment #3 from H.J. Lu  ---
Created attachment 57293
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57293=edit
An updated patch

[Bug target/113711] APX instruction set and instructions longer than 15 bytes (assembly warning)

2024-02-02 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113711

--- Comment #2 from H.J. Lu  ---
Created attachment 57288
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57288=edit
Add BN constraint for APX NDD instructions

Since the instruction length of APX NDD instructions:

op imm, mem, reg

may exceed the size limit of 15 byes, add BN constraint which is a
memory operand when TARGET_APX_NDD is disabled. For all TARGET_APX_NDD
patterns with

op imm, mem, reg

replace m with BN in operand 1 constraint for alternative with immediate
operand 2.

This patch isn't complete. We need to update all relevant TARGET_APX_NDD
patterns.