[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2026-01-08 Thread avinashd at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

Avinash Jayakar  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #21 from Avinash Jayakar  ---
Resolving this bug since its now fixed on 13,14,15 and trunk

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2026-01-05 Thread avinashd at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

--- Comment #20 from Avinash Jayakar  ---
Fixed on 13,14,15 and trunk

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2026-01-05 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

--- Comment #19 from GCC Commits  ---
The releases/gcc-13 branch has been updated by Avinash Jayakar
:

https://gcc.gnu.org/g:0fe9607591c911d1f6b807e5353a1e1a99d249ca

commit r13-10028-g0fe9607591c911d1f6b807e5353a1e1a99d249ca
Author: Avinash Jayakar 
Date:   Sat Nov 8 09:57:59 2025 +0530

isel: Check bounds before converting VIEW_CONVERT to VEC_SET.

The function gimple_expand_vec_set_expr in the isel pass, converted
VIEW_CONVERT_EXPR to VEC_SET_EXPR without checking the bounds on the index,
which cause ICE on targets that supported VEC_SET_EXPR like x86 and
powerpc.
This patch adds a bound check on the index operand and rejects the
conversion
if index is out of bound.

2026-01-05  Avinash Jayakar  

gcc/ChangeLog:
PR tree-optimization/122126
* gimple-isel.cc (gimple_expand_vec_set_extract_expr): Add bound
check.

gcc/testsuite/ChangeLog:
PR tree-optimization/122126
* gcc.dg/pr122126_vextr.c: New test.
* gcc.dg/pr122126_vset.c: New test.

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-11-30 Thread avinashd at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

--- Comment #18 from Avinash Jayakar  ---
(In reply to Jakub Jelinek from comment #16)
> Also, why the idx var when there is tree idx = TREE_OPERAND (ref, 1); (or
> for 13 tree idx = TREE_OPERAND (lhs, 1);) a few lines earlier?

Sorry I did not notice this. We can use the pos directly as well.
I think doing changes after review, I had some name changes but did not notice
this duplication.

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-11-30 Thread avinashd at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

--- Comment #17 from Avinash Jayakar  ---
Apologies for this, will not repeat this mistake again. (In reply to Eric
Botcazou from comment #15)
> Please test changes on every branch when you're backporting them:
> 
Apologies for this, will not repeat it again. I have reverted the commit for
now.

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-11-30 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

--- Comment #16 from Jakub Jelinek  ---
Also, why the idx var when there is tree idx = TREE_OPERAND (ref, 1); (or for
13 tree idx = TREE_OPERAND (lhs, 1);) a few lines earlier?

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-11-29 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

Eric Botcazou  changed:

   What|Removed |Added

 CC||ebotcazou at gcc dot gnu.org

--- Comment #15 from Eric Botcazou  ---
Please test changes on every branch when you're backporting them:

In file included from /home/eric/cvs/gcc-13/gcc/gimple-isel.cc:25:0:
/home/eric/cvs/gcc-13/gcc/gimple-isel.cc: In function ‘bool
gimple_expand_vec_set_expr(function*, gimple_stmt_iterator*)’:
/home/eric/cvs/gcc-13/gcc/gimple-isel.cc:80:32: error: ‘ref’ was not declared
in this scope
   tree idx = TREE_OPERAND (ref, 1);
^
/home/eric/cvs/gcc-13/gcc/tree.h:473:37: note: in definition of macro
‘TREE_OPERAND_CHECK’
 #define TREE_OPERAND_CHECK(T, I)  ((T)->exp.operands[I])
 ^
/home/eric/cvs/gcc-13/gcc/gimple-isel.cc:80:18: note: in expansion of macro
‘TREE_OPERAND’
   tree idx = TREE_OPERAND (ref, 1);
  ^~~~
make[3]: *** [Makefile:1157: gimple-isel.o] Error 1
make[3]: *** Waiting for unfinished jobs
rm fsf-funding.pod gfdl.pod cpp.pod lto-dump.pod gpl.pod gcc.pod gcov.pod
gcov-dump.pod gcov-tool.pod

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-11-28 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

--- Comment #14 from GCC Commits  ---
The releases/gcc-15 branch has been updated by Avinash Jayakar
:

https://gcc.gnu.org/g:481c3ecd2962f395c5d4e6bfddb414b788238bda

commit r15-10559-g481c3ecd2962f395c5d4e6bfddb414b788238bda
Author: Avinash Jayakar 
Date:   Sat Nov 8 09:57:59 2025 +0530

isel: Check bounds before converting VIEW_CONVERT to VEC_SET.

The function gimple_expand_vec_set_expr in the isel pass, converted
VIEW_CONVERT_EXPR to VEC_SET_EXPR without checking the bounds on the index,
which cause ICE on targets that supported VEC_SET_EXPR like x86 and
powerpc.
This patch adds a bound check on the index operand and rejects the
conversion
if index is out of bound.

2025-11-08  Avinash Jayakar  

gcc/ChangeLog:
PR tree-optimization/122126
* gimple-isel.cc (gimple_expand_vec_set_extract_expr): Add bound
check.

gcc/testsuite/ChangeLog:
PR tree-optimization/122126
* gcc.dg/pr122126_vextr.c: New test.
* gcc.dg/pr122126_vset.c: New test.

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-11-28 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

--- Comment #13 from GCC Commits  ---
The releases/gcc-14 branch has been updated by Avinash Jayakar
:

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

commit r14-12182-gdb138aff1247feb9b755443c80d226fb601ebe49
Author: Avinash Jayakar 
Date:   Sat Nov 8 09:57:59 2025 +0530

isel: Check bounds before converting VIEW_CONVERT to VEC_SET.

The function gimple_expand_vec_set_expr in the isel pass, converted
VIEW_CONVERT_EXPR to VEC_SET_EXPR without checking the bounds on the index,
which cause ICE on targets that supported VEC_SET_EXPR like x86 and
powerpc.
This patch adds a bound check on the index operand and rejects the
conversion
if index is out of bound.

2025-11-08  Avinash Jayakar  

gcc/ChangeLog:
PR tree-optimization/122126
* gimple-isel.cc (gimple_expand_vec_set_extract_expr): Add bound
check.

gcc/testsuite/ChangeLog:
PR tree-optimization/122126
* gcc.dg/pr122126_vextr.c: New test.
* gcc.dg/pr122126_vset.c: New test.

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-11-28 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

--- Comment #12 from GCC Commits  ---
The releases/gcc-13 branch has been updated by Avinash Jayakar
:

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

commit r13-9987-gd02cd309ad2f4b79f74f477bc3f271b884c916b5
Author: Avinash Jayakar 
Date:   Sat Nov 8 09:57:59 2025 +0530

isel: Check bounds before converting VIEW_CONVERT to VEC_SET.

The function gimple_expand_vec_set_expr in the isel pass, converted
VIEW_CONVERT_EXPR to VEC_SET_EXPR without checking the bounds on the index,
which cause ICE on targets that supported VEC_SET_EXPR like x86 and
powerpc.
This patch adds a bound check on the index operand and rejects the
conversion
if index is out of bound.

2025-11-08  Avinash Jayakar  

gcc/ChangeLog:
PR tree-optimization/122126
* gimple-isel.cc (gimple_expand_vec_set_extract_expr): Add bound
check.

gcc/testsuite/ChangeLog:
PR tree-optimization/122126
* gcc.dg/pr122126_vextr.c: New test.
* gcc.dg/pr122126_vset.c: New test.

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-11-23 Thread avinashd at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

--- Comment #11 from Avinash Jayakar  ---
(In reply to Jakub Jelinek from comment #10)
> So fixed for 16 for now?

yes this is fixed in trunk.

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-11-21 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #10 from Jakub Jelinek  ---
So fixed for 16 for now?

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-11-08 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

--- Comment #9 from GCC Commits  ---
The trunk branch has been updated by Avinash Jayakar :

https://gcc.gnu.org/g:7d966cc35ad01d70cd9bfb6f531c938a7b6110b7

commit r16-5097-g7d966cc35ad01d70cd9bfb6f531c938a7b6110b7
Author: Avinash Jayakar 
Date:   Sat Nov 8 09:57:59 2025 +0530

isel: Check bounds before converting VIEW_CONVERT to VEC_SET.

The function gimple_expand_vec_set_expr in the isel pass, converted
VIEW_CONVERT_EXPR to VEC_SET_EXPR without checking the bounds on the index,
which cause ICE on targets that supported VEC_SET_EXPR like x86 and
powerpc.
This patch adds a bound check on the index operand and rejects the
conversion
if index is out of bound.

2025-11-08  Avinash Jayakar  

gcc/ChangeLog:
PR tree-optimization/122126
* gimple-isel.cc (gimple_expand_vec_set_extract_expr): Add bound
check.

gcc/testsuite/ChangeLog:
PR tree-optimization/122126
* gcc.dg/pr122126_vextr.c: New test.
* gcc.dg/pr122126_vset.c: New test.

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-11-05 Thread avinashd at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

--- Comment #8 from Avinash Jayakar  ---
(In reply to Avinash Jayakar from comment #7)
> Created attachment 62715 [details]
> proposed patch for pr122126 for powerpc64le
> 
> In powerpc64le, I see that we generate vsx_set insn during expand pass,
> without actually checking for the index operand.
> Here is the proposed fix for the powerpc64le backend, if the approach is ok
> I can create submit the patch. 
> 
> Should we do a similar thing for the x86?

Please ignore this, I was doing the wrong thing. As andrew suggested I will
update the gimple_expand_vec_set_extract_expr as follows

  tree op0 = TREE_OPERAND (ref, 0);
  tree view_op0 = TREE_OPERAND (op0, 0);
  tree op1 = TREE_OPERAND (ref, 1);

  if (!TYPE_VECTOR_SUBPARTS (view_op0).is_constant ())
return false;

  if (TREE_CODE (op1) == INTEGER_CST && (!tree_fits_uhwi_p (op1) || 
tree_to_uhwi (op1) > TYPE_VECTOR_SUBPARTS (view_op0).to_constant ()))
return false;

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-11-05 Thread avinashd at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

Avinash Jayakar  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |avinashd at gcc dot 
gnu.org
 CC||avinashd at gcc dot gnu.org

--- Comment #7 from Avinash Jayakar  ---
Created attachment 62715
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62715&action=edit
proposed patch for pr122126 for powerpc64le

In powerpc64le, I see that we generate vsx_set insn during expand pass, without
actually checking for the index operand.
Here is the proposed fix for the powerpc64le backend, if the approach is ok I
can create submit the patch. 

Should we do a similar thing for the x86?

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-10-02 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

--- Comment #6 from Andrew Pinski  ---
Another testcase but with `-O2 -mavx2 -fno-tree-dse -fno-tree-dce`:
```
#define vect16 __attribute__((vector_size(16)))
void sink(void*);
vect16 unsigned func_54(vect16 unsigned BS_VAR_0, int t, int l) {
  BS_VAR_0[12] = 4;
  return BS_VAR_0;
}
```

If nobody gets to it by the next week, I will look into the fix. Should be
simple as saying:
if (TREE_CODE (x) == INTEGER_CST &&
(!tree_fits_uhwi_p (x)
 || tree_to_uhwi (x) < TYPE_VECTOR_SUBPARTS (type_y)))
  reject;

Or something similar since TYPE_VECTOR_SUBPARTS might be not be a constant.

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-10-02 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

Andrew Pinski  changed:

   What|Removed |Added

  Known to fail||11.1.0
   Keywords|needs-bisection |
  Known to work||10.5.0

--- Comment #5 from Andrew Pinski  ---
Reduced testcase:
```
#define vect16 __attribute__((vector_size(16)))
void func_54() {
  volatile vect16 unsigned BS_VAR_0;
  BS_VAR_0[12] = 4;
}
```

This started in GCC 11 with r11-3486-g683e55facfd5c1 .

[Bug middle-end/122126] [13/14/15/16 regression] X86-64 AVX2 and PowerPC64LE: crash at -O2/3

2025-10-02 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122126

Andrew Pinski  changed:

   What|Removed |Added

  Known to work|13.4.1  |
Summary|[14/15/16 regression]   |[13/14/15/16 regression]
   |X86-64 AVX2 and |X86-64 AVX2 and
   |PowerPC64LE: crash at -O2/3 |PowerPC64LE: crash at -O2/3

--- Comment #4 from Andrew Pinski  ---
So in forwprop4 we have:
  VIEW_CONVERT_EXPR(BS_VAR_0)[690501320391798396] = 0;

Which is obvious undefined at this point.
And then isel comes along and changes it to:
  _38 = BS_VAR_0;
  _57 = .VEC_SET (_38, 0, 690501320391798396);
  BS_VAR_0 = _57;

So isel maybe should have a check on the argument before changing.

In GCC 12/13, it is all DCEd.
changing BS_VAR_0 to be volatile causes the ICE to show up in GCC 12/13:
volatile  BS_VEC(uint32, 4) BS_VAR_0;


In GCC 11 there is not a block duplicated it seems:
```
  # iftmp.2_6 = PHI <0(5), 690501320391798396(14)>
  _17 ={v} BS_VAR_0;
  _16 = .VEC_SET (_17, 0, iftmp.2_6);
  BS_VAR_0 ={v} _16;
```