[Bug middle-end/111699] [14 Regression] ICE: SIGSEGV: infinite recursion in fold_build3_loc/fold_ternary_loc/generic_simplify_VEC_COND_EXPR

2023-10-06 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111699

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|14.0|13.3
  Known to work|13.2.1  |10.4.0, 14.0
  Known to fail|14.0|

--- Comment #7 from Andrew Pinski  ---
Will be backporting it in a few days to the other open branches as this is a
latent bug.

[Bug middle-end/111699] [14 Regression] ICE: SIGSEGV: infinite recursion in fold_build3_loc/fold_ternary_loc/generic_simplify_VEC_COND_EXPR

2023-10-06 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111699

--- Comment #6 from CVS Commits  ---
The trunk branch has been updated by Andrew Pinski :

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

commit r14-4432-ge77428a9a336f57e3efe3eff95f2b491d7e9be14
Author: Andrew Pinski 
Date:   Thu Oct 5 12:21:19 2023 -0700

MATCH: Fix infinite loop between `vec_cond(vec_cond(a,b,0), c, d)` and `a &
b`

Match has a pattern which converts `vec_cond(vec_cond(a,b,0), c, d)`
into `vec_cond(a & b, c, d)` but since in this case a is a comparison
fold will change `a & b` back into `vec_cond(a,b,0)` which causes an
infinite loop.
The best way to fix this is to enable the patterns for
vec_cond(*,vec_cond,*)
only for GIMPLE so we don't get an infinite loop for fold any more.

Note this is a latent bug since these patterns were added in
r11-2577-g229752afe3156a
and was exposed by r14-3350-g47b833a9abe1 where now able to remove a
VIEW_CONVERT_EXPR.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR middle-end/111699

gcc/ChangeLog:

* match.pd ((c ? a : b) op d, (c ? a : b) op (c ? d : e),
(v ? w : 0) ? a : b, c1 ? c2 ? a : b : b): Enable only for GIMPLE.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/pr111699-1.c: New test.

[Bug middle-end/111699] [14 Regression] ICE: SIGSEGV: infinite recursion in fold_build3_loc/fold_ternary_loc/generic_simplify_VEC_COND_EXPR

2023-10-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111699

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||patch
URL||https://gcc.gnu.org/piperma
   ||il/gcc-patches/2023-October
   ||/632128.html

--- Comment #5 from Andrew Pinski  ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-October/632128.html

[Bug middle-end/111699] [14 Regression] ICE: SIGSEGV: infinite recursion in fold_build3_loc/fold_ternary_loc/generic_simplify_VEC_COND_EXPR

2023-10-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111699

Andrew Pinski  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |pinskia at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

--- Comment #4 from Andrew Pinski  ---
I have a patch.

[Bug middle-end/111699] [14 Regression] ICE: SIGSEGV: infinite recursion in fold_build3_loc/fold_ternary_loc/generic_simplify_VEC_COND_EXPR

2023-10-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111699

Andrew Pinski  changed:

   What|Removed |Added

   Keywords|needs-bisection |

--- Comment #3 from Andrew Pinski  ---
this was exposed by my commit (r14-3350-g47b833a9abe1) which added:
/* Likewise for view_convert of nop_conversions. */
(simplify
 (view_convert (vec_cond:s @0 @1 @2))
 (if (VECTOR_TYPE_P (type) && VECTOR_TYPE_P (TREE_TYPE (@1))
  && known_eq (TYPE_VECTOR_SUBPARTS (type),
   TYPE_VECTOR_SUBPARTS (TREE_TYPE (@1)))
  && tree_nop_conversion_p (TREE_TYPE (type), TREE_TYPE (TREE_TYPE (@1
  (vec_cond @0 (view_convert! @1) (view_convert! @2

Before we have a VIEW_CONVERT around the vec_cond which prevented the infinite
loop but now we don't ...

[Bug middle-end/111699] [14 Regression] ICE: SIGSEGV: infinite recursion in fold_build3_loc/fold_ternary_loc/generic_simplify_VEC_COND_EXPR

2023-10-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111699

--- Comment #2 from Andrew Pinski  ---
(simplify
 (vec_cond (vec_cond:s @0 @3 integer_zerop) @1 @2)
 (if (optimize_vectors_before_lowering_p () && types_match (@0, @3))
  (vec_cond (bit_and @0 @3) @1 @2)))

goes into an infinite loop with fold_build3 as the fold_build2:BIT_AND of:
(gdb) p debug_generic_expr(captures[1])
v == { 0, 0, 0, 0, 0, 0, 0, 0 }
$9 = void
(gdb) p debug_generic_expr(captures[2])
{ 0, -1, -1, -1, -1, -1, -1, -1 }

Creates a vec_cond ...

[Bug middle-end/111699] [14 Regression] ICE: SIGSEGV: infinite recursion in fold_build3_loc/fold_ternary_loc/generic_simplify_VEC_COND_EXPR

2023-10-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111699

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed||2023-10-05
 Target|aarch64-unknown-linux-gnu   |
 Status|UNCONFIRMED |NEW
   Host|x86_64-pc-linux-gnu |
 Ever confirmed|0   |1

--- Comment #1 from Andrew Pinski  ---
Here is a testcase which fails everywhere:
```
typedef unsigned char __attribute__((__vector_size__ (8))) V;

V
foo (V v)
{
  return (V) 0x107B9A7FF >= (v <= 0);
}
```

AARCH64 defaults to unsigned char which is why it fails there with the original
testcase.

[Bug middle-end/111699] [14 Regression] ICE: SIGSEGV: infinite recursion in fold_build3_loc/fold_ternary_loc/generic_simplify_VEC_COND_EXPR

2023-10-05 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111699

Richard Biener  changed:

   What|Removed |Added

   Keywords||needs-bisection
   Target Milestone|--- |14.0