public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/108237] New: [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O
@ 2022-12-27 22:52 zsojka at seznam dot cz
  2022-12-28  8:52 ` [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081 marxin at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: zsojka at seznam dot cz @ 2022-12-27 22:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108237

            Bug ID: 108237
           Summary: [13 Regression] ICE: in gimple_expand_vec_cond_expr,
                    at gimple-isel.cc:281 at -O
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu

Created attachment 54158
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54158&action=edit
reduced testcase

Compiler output:
$ x86_64-pc-linux-gnu-gcc -O testcase.c
during GIMPLE pass: isel
testcase.c: In function 'foo':
testcase.c:8:1: internal compiler error: in gimple_expand_vec_cond_expr, at
gimple-isel.cc:281
    8 | foo (void)
      | ^~~
0x7f3f7a gimple_expand_vec_cond_expr
        /repo/gcc-trunk/gcc/gimple-isel.cc:281
0x1610976 gimple_expand_vec_exprs
        /repo/gcc-trunk/gcc/gimple-isel.cc:311
0x1610976 execute
        /repo/gcc-trunk/gcc/gimple-isel.cc:365
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r13-4906-20221227204950-g7c755fd9018-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--disable-bootstrap --with-cloog --with-ppl --with-isl
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r13-4906-20221227204950-g7c755fd9018-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.0.0 20221227 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081
  2022-12-27 22:52 [Bug middle-end/108237] New: [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O zsojka at seznam dot cz
@ 2022-12-28  8:52 ` marxin at gcc dot gnu.org
  2023-01-03 15:57 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-12-28  8:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108237

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |13.0
     Ever confirmed|0                           |1
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
            Summary|[13 Regression] ICE: in     |[13 Regression] ICE: in
                   |gimple_expand_vec_cond_expr |gimple_expand_vec_cond_expr
                   |, at gimple-isel.cc:281 at  |, at gimple-isel.cc:281 at
                   |-O                          |-O since
                   |                            |r13-1085-g90467f0ad649d081
   Last reconfirmed|                            |2022-12-28

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r13-1085-g90467f0ad649d081

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081
  2022-12-27 22:52 [Bug middle-end/108237] New: [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O zsojka at seznam dot cz
  2022-12-28  8:52 ` [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081 marxin at gcc dot gnu.org
@ 2023-01-03 15:57 ` jakub at gcc dot gnu.org
  2023-01-03 16:16 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-03 15:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108237

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Bet another case of post-veclower folding that turns out something we can
handle into something we can't.
In this case fre5 after veclower21 triggers:
/* Simplify comparison of something with itself.  For IEEE
   floating-point, we can only do some of these simplifications.  */
(for cmp (eq ge le)
 (simplify
  (cmp @0 @0)
  (if (! FLOAT_TYPE_P (TREE_TYPE (@0))
       || ! tree_expr_maybe_nan_p (@0))
   { constant_boolean_node (true, type); }
and
 /* (X & Y) == X becomes (X & ~Y) == 0.  */
 (simplify
  (cmp:c (bit_and:c @0 @1) @0)
  (cmp (bit_and @0 (bit_not! @1)) { build_zero_cst (TREE_TYPE (@0)); }))
match.pd simplifications:
   u.0_3 = u;
   _12 = VIEW_CONVERT_EXPR<unsigned char>(u.0_3);
   _2 = {_12};
-  _15 = VIEW_CONVERT_EXPR<unsigned char>(u.0_3);
-  _16 = _12 == _15;
-  _17 = (_Bool) _16;
-  _18 = _16 & 1;
-  _19 = (signed char) _18;
-  _20 = -_19;
-  _5 = {_20};
-  _13 = VIEW_CONVERT_EXPR<unsigned char>(_5);
-  _6 = (long long unsigned int) _13;
-  _1 = {_6, _6};
   v.2_7 = v;
-  _8 = _1 & v.2_7;
+  _8 = v.2_7 & { 255, 255 };
   _9 = v.2_7 != _8;
   _10 = VEC_COND_EXPR <_9, { -1, -1 }, { 0, 0 }>;
   w_14 = VIEW_CONVERT_EXPR<V>(_10);

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081
  2022-12-27 22:52 [Bug middle-end/108237] New: [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O zsojka at seznam dot cz
  2022-12-28  8:52 ` [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081 marxin at gcc dot gnu.org
  2023-01-03 15:57 ` jakub at gcc dot gnu.org
@ 2023-01-03 16:16 ` jakub at gcc dot gnu.org
  2023-01-03 16:35 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-03 16:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108237

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think the actual problem is though:
/* Transform comparisons of the form (X & Y) CMP 0 to X CMP2 Z
   where ~Y + 1 == pow2 and Z = ~Y.  */
(for cst (VECTOR_CST INTEGER_CST)
 (for cmp (eq ne)
      icmp (le gt)
  (simplify
   (cmp (bit_and:c@2 @0 cst@1) integer_zerop)
    (with { tree csts = bitmask_inv_cst_vector_p (@1); }
     (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)))
      (with { auto optab = VECTOR_TYPE_P (TREE_TYPE (@1))
                         ? optab_vector : optab_default;
              tree utype = unsigned_type_for (TREE_TYPE (@1)); }
       (if (target_supports_op_p (utype, icmp, optab)
            || (optimize_vectors_before_lowering_p ()
                && (!target_supports_op_p (type, cmp, optab)
                    || !target_supports_op_p (type, BIT_AND_EXPR, optab))))
        (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
         (icmp @0 { csts; })
         (icmp (view_convert:utype @0) { csts; })))))))))
pattern, for V2DImode != or == works, but > does not.
I wonder how it could trigger though because target_supports_op_p (utype, icmp,
optab)
is false.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081
  2022-12-27 22:52 [Bug middle-end/108237] New: [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2023-01-03 16:16 ` jakub at gcc dot gnu.org
@ 2023-01-03 16:35 ` jakub at gcc dot gnu.org
  2023-01-03 16:40 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-03 16:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108237

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ah, I see, it is forwprop4 which does that:
+Applying pattern match.pd:6223, generic-match.cc:75158
...
-  _15 = v.2_7 & { 18446744073709551360, 18446744073709551360 };
-  _9 = _15 != { 0, 0 };
+  _9 = v.2_7 > { 255, 255 };

and the reason why it happens can be seen in the Applying line, it isn't GIMPLE
but GENERIC even when it happens so late.
#0  optimize_vectors_before_lowering_p () at ../../gcc/generic-match-head.cc:93
#1  0x00000000019d3302 in generic_simplify_NE_EXPR (loc=2147483658,
code=NE_EXPR, type=<vector_type 0x7fffea2ddb28>, _p0=<bit_and_expr
0x7fffea304280>, 
    _p1=<vector_cst 0x7fffea308cf0>) at generic-match.cc:75147
#2  0x0000000001a46486 in generic_simplify (loc=2147483658, code=NE_EXPR,
type=<vector_type 0x7fffea2ddb28>, _p0=<bit_and_expr 0x7fffea304280>,
_p1=<vector_cst 0x7fffea308cf0>)
    at generic-match.cc:102839
#3  0x000000000085e140 in fold_binary_loc (loc=2147483658, code=NE_EXPR,
type=<vector_type 0x7fffea2ddb28>, op0=<bit_and_expr 0x7fffea304280>,
op1=<vector_cst 0x7fffea308cf0>)
    at ../../gcc/fold-const.cc:10924
#4  0x0000000000f5c7ea in combine_cond_expr_cond (stmt=<gimple_assign
0x7fffea3020b0>, code=NE_EXPR, type=<vector_type 0x7fffea2ddb28>,
op0=<bit_and_expr 0x7fffea304280>, 
    op1=<vector_cst 0x7fffea308cf0>, invariant_only=false) at
../../gcc/tree-ssa-forwprop.cc:387
#5  0x0000000000f5ca80 in forward_propagate_into_comparison_1
(stmt=<gimple_assign 0x7fffea3020b0>, code=NE_EXPR, type=<vector_type
0x7fffea2ddb28>, 
    op0=<ssa_name 0x7fffea3014c8 15>, op1=<vector_cst 0x7fffea308cf0>) at
../../gcc/tree-ssa-forwprop.cc:446
#6  0x0000000000f5cc71 in forward_propagate_into_comparison
(gsi=0x7fffffffd740) at ../../gcc/tree-ssa-forwprop.cc:493
#7  0x0000000000f6bfff in (anonymous namespace)::pass_forwprop::execute
(this=0x37a2170, fun=0x7fffea2fd000) at ../../gcc/tree-ssa-forwprop.cc:3753

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081
  2022-12-27 22:52 [Bug middle-end/108237] New: [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2023-01-03 16:35 ` jakub at gcc dot gnu.org
@ 2023-01-03 16:40 ` jakub at gcc dot gnu.org
  2023-01-04  9:55 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-03 16:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108237

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 54179
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54179&action=edit
gcc13-pr108237.patch

Untested fix.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081
  2022-12-27 22:52 [Bug middle-end/108237] New: [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2023-01-03 16:40 ` jakub at gcc dot gnu.org
@ 2023-01-04  9:55 ` cvs-commit at gcc dot gnu.org
  2023-01-04  9:56 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-04  9:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108237

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:345dffd0d4ebff7e705dfff1a8a72017a167120a

commit r13-4989-g345dffd0d4ebff7e705dfff1a8a72017a167120a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 4 10:54:38 2023 +0100

    generic-match-head: Don't assume GENERIC folding is done only early
[PR108237]

    We ICE on the following testcase, because a valid V2DImode
    != comparison is folded into an unsupported V2DImode > comparison.
    The match.pd pattern which does this looks like:
    /* Transform comparisons of the form (X & Y) CMP 0 to X CMP2 Z
       where ~Y + 1 == pow2 and Z = ~Y.  */
    (for cst (VECTOR_CST INTEGER_CST)
     (for cmp (eq ne)
          icmp (le gt)
      (simplify
       (cmp (bit_and:c@2 @0 cst@1) integer_zerop)
        (with { tree csts = bitmask_inv_cst_vector_p (@1); }
         (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)))
          (with { auto optab = VECTOR_TYPE_P (TREE_TYPE (@1))
                             ? optab_vector : optab_default;
                  tree utype = unsigned_type_for (TREE_TYPE (@1)); }
           (if (target_supports_op_p (utype, icmp, optab)
                || (optimize_vectors_before_lowering_p ()
                    && (!target_supports_op_p (type, cmp, optab)
                        || !target_supports_op_p (type, BIT_AND_EXPR, optab))))
            (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
             (icmp @0 { csts; })
             (icmp (view_convert:utype @0) { csts; })))))))))
    and that optimize_vectors_before_lowering_p () guarded stuff there
    already deals with this problem, not trying to fold a supported comparison
    into a non-supported one.  The reason it doesn't work in this case is that
    it isn't GIMPLE folding which does this, but GENERIC folding done during
    forwprop4 - forward_propagate_into_comparison ->
forward_propagate_into_comparison_1
    -> combine_cond_expr_cond -> fold_binary_loc -> generic_simplify
    and we simply assumed that GENERIC folding happens only before
    gimplification.

    The following patch fixes that by checking cfun properties instead of
    always returning true in those cases.

    2023-01-04  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/108237
            * generic-match-head.cc: Include tree-pass.h.
            (canonicalize_math_p, optimize_vectors_before_lowering_p): Define
            to false if cfun and cfun->curr_properties has PROP_gimple_opt_math
            resp. PROP_gimple_lvec property set.

            * gcc.c-torture/compile/pr108237.c: New test.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081
  2022-12-27 22:52 [Bug middle-end/108237] New: [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2023-01-04  9:55 ` cvs-commit at gcc dot gnu.org
@ 2023-01-04  9:56 ` jakub at gcc dot gnu.org
  2023-01-09 10:08 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-04  9:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108237

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
           Priority|P3                          |P1

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081
  2022-12-27 22:52 [Bug middle-end/108237] New: [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2023-01-04  9:56 ` jakub at gcc dot gnu.org
@ 2023-01-09 10:08 ` rguenth at gcc dot gnu.org
  2023-02-10 17:45 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-01-09 10:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108237

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Btw, I've also backported the offending rev. to the GCC 12 branch, so
presumably we want this fix also there even if just out of caution.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081
  2022-12-27 22:52 [Bug middle-end/108237] New: [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O zsojka at seznam dot cz
                   ` (7 preceding siblings ...)
  2023-01-09 10:08 ` rguenth at gcc dot gnu.org
@ 2023-02-10 17:45 ` cvs-commit at gcc dot gnu.org
  2023-05-02 20:13 ` cvs-commit at gcc dot gnu.org
  2023-05-03 15:20 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-10 17:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108237

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:4c8e17a6a578b9eb15cd210651b6ea273022db39

commit r12-9136-g4c8e17a6a578b9eb15cd210651b6ea273022db39
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 4 10:54:38 2023 +0100

    generic-match-head: Don't assume GENERIC folding is done only early
[PR108237]

    We ICE on the following testcase, because a valid V2DImode
    != comparison is folded into an unsupported V2DImode > comparison.
    The match.pd pattern which does this looks like:
    /* Transform comparisons of the form (X & Y) CMP 0 to X CMP2 Z
       where ~Y + 1 == pow2 and Z = ~Y.  */
    (for cst (VECTOR_CST INTEGER_CST)
     (for cmp (eq ne)
          icmp (le gt)
      (simplify
       (cmp (bit_and:c@2 @0 cst@1) integer_zerop)
        (with { tree csts = bitmask_inv_cst_vector_p (@1); }
         (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)))
          (with { auto optab = VECTOR_TYPE_P (TREE_TYPE (@1))
                             ? optab_vector : optab_default;
                  tree utype = unsigned_type_for (TREE_TYPE (@1)); }
           (if (target_supports_op_p (utype, icmp, optab)
                || (optimize_vectors_before_lowering_p ()
                    && (!target_supports_op_p (type, cmp, optab)
                        || !target_supports_op_p (type, BIT_AND_EXPR, optab))))
            (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
             (icmp @0 { csts; })
             (icmp (view_convert:utype @0) { csts; })))))))))
    and that optimize_vectors_before_lowering_p () guarded stuff there
    already deals with this problem, not trying to fold a supported comparison
    into a non-supported one.  The reason it doesn't work in this case is that
    it isn't GIMPLE folding which does this, but GENERIC folding done during
    forwprop4 - forward_propagate_into_comparison ->
forward_propagate_into_comparison_1
    -> combine_cond_expr_cond -> fold_binary_loc -> generic_simplify
    and we simply assumed that GENERIC folding happens only before
    gimplification.

    The following patch fixes that by checking cfun properties instead of
    always returning true in those cases.

    2023-01-04  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/108237
            * generic-match-head.cc: Include tree-pass.h.
            (canonicalize_math_p, optimize_vectors_before_lowering_p): Define
            to false if cfun and cfun->curr_properties has PROP_gimple_opt_math
            resp. PROP_gimple_lvec property set.

            * gcc.c-torture/compile/pr108237.c: New test.

    (cherry picked from commit 345dffd0d4ebff7e705dfff1a8a72017a167120a)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081
  2022-12-27 22:52 [Bug middle-end/108237] New: [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O zsojka at seznam dot cz
                   ` (8 preceding siblings ...)
  2023-02-10 17:45 ` cvs-commit at gcc dot gnu.org
@ 2023-05-02 20:13 ` cvs-commit at gcc dot gnu.org
  2023-05-03 15:20 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-02 20:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108237

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

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

commit r11-10697-ge7496d6571624547b52264b80469bd071217ae02
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 4 10:54:38 2023 +0100

    generic-match-head: Don't assume GENERIC folding is done only early
[PR108237]

    We ICE on the following testcase, because a valid V2DImode
    != comparison is folded into an unsupported V2DImode > comparison.
    The match.pd pattern which does this looks like:
    /* Transform comparisons of the form (X & Y) CMP 0 to X CMP2 Z
       where ~Y + 1 == pow2 and Z = ~Y.  */
    (for cst (VECTOR_CST INTEGER_CST)
     (for cmp (eq ne)
          icmp (le gt)
      (simplify
       (cmp (bit_and:c@2 @0 cst@1) integer_zerop)
        (with { tree csts = bitmask_inv_cst_vector_p (@1); }
         (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)))
          (with { auto optab = VECTOR_TYPE_P (TREE_TYPE (@1))
                             ? optab_vector : optab_default;
                  tree utype = unsigned_type_for (TREE_TYPE (@1)); }
           (if (target_supports_op_p (utype, icmp, optab)
                || (optimize_vectors_before_lowering_p ()
                    && (!target_supports_op_p (type, cmp, optab)
                        || !target_supports_op_p (type, BIT_AND_EXPR, optab))))
            (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
             (icmp @0 { csts; })
             (icmp (view_convert:utype @0) { csts; })))))))))
    and that optimize_vectors_before_lowering_p () guarded stuff there
    already deals with this problem, not trying to fold a supported comparison
    into a non-supported one.  The reason it doesn't work in this case is that
    it isn't GIMPLE folding which does this, but GENERIC folding done during
    forwprop4 - forward_propagate_into_comparison ->
forward_propagate_into_comparison_1
    -> combine_cond_expr_cond -> fold_binary_loc -> generic_simplify
    and we simply assumed that GENERIC folding happens only before
    gimplification.

    The following patch fixes that by checking cfun properties instead of
    always returning true in those cases.

    2023-01-04  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/108237
            * generic-match-head.c: Include tree-pass.h.
            (canonicalize_math_p, optimize_vectors_before_lowering_p): Define
            to false if cfun and cfun->curr_properties has PROP_gimple_opt_math
            resp. PROP_gimple_lvec property set.

            * gcc.c-torture/compile/pr108237.c: New test.

    (cherry picked from commit 345dffd0d4ebff7e705dfff1a8a72017a167120a)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081
  2022-12-27 22:52 [Bug middle-end/108237] New: [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O zsojka at seznam dot cz
                   ` (9 preceding siblings ...)
  2023-05-02 20:13 ` cvs-commit at gcc dot gnu.org
@ 2023-05-03 15:20 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-03 15:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108237

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

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

commit r10-11354-ga91ca4212faca201291633a8016c5c47dbba07e2
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 4 10:54:38 2023 +0100

    generic-match-head: Don't assume GENERIC folding is done only early
[PR108237]

    We ICE on the following testcase, because a valid V2DImode
    != comparison is folded into an unsupported V2DImode > comparison.
    The match.pd pattern which does this looks like:
    /* Transform comparisons of the form (X & Y) CMP 0 to X CMP2 Z
       where ~Y + 1 == pow2 and Z = ~Y.  */
    (for cst (VECTOR_CST INTEGER_CST)
     (for cmp (eq ne)
          icmp (le gt)
      (simplify
       (cmp (bit_and:c@2 @0 cst@1) integer_zerop)
        (with { tree csts = bitmask_inv_cst_vector_p (@1); }
         (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)))
          (with { auto optab = VECTOR_TYPE_P (TREE_TYPE (@1))
                             ? optab_vector : optab_default;
                  tree utype = unsigned_type_for (TREE_TYPE (@1)); }
           (if (target_supports_op_p (utype, icmp, optab)
                || (optimize_vectors_before_lowering_p ()
                    && (!target_supports_op_p (type, cmp, optab)
                        || !target_supports_op_p (type, BIT_AND_EXPR, optab))))
            (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
             (icmp @0 { csts; })
             (icmp (view_convert:utype @0) { csts; })))))))))
    and that optimize_vectors_before_lowering_p () guarded stuff there
    already deals with this problem, not trying to fold a supported comparison
    into a non-supported one.  The reason it doesn't work in this case is that
    it isn't GIMPLE folding which does this, but GENERIC folding done during
    forwprop4 - forward_propagate_into_comparison ->
forward_propagate_into_comparison_1
    -> combine_cond_expr_cond -> fold_binary_loc -> generic_simplify
    and we simply assumed that GENERIC folding happens only before
    gimplification.

    The following patch fixes that by checking cfun properties instead of
    always returning true in those cases.

    2023-01-04  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/108237
            * generic-match-head.c: Include tree-pass.h.
            (canonicalize_math_p): Define to false if cfun and
            cfun->curr_properties has PROP_gimple_opt_math resp.
PROP_gimple_lvec
            property set.

            * gcc.c-torture/compile/pr108237.c: New test.

    (cherry picked from commit 345dffd0d4ebff7e705dfff1a8a72017a167120a)

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-05-03 15:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-27 22:52 [Bug middle-end/108237] New: [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O zsojka at seznam dot cz
2022-12-28  8:52 ` [Bug middle-end/108237] [13 Regression] ICE: in gimple_expand_vec_cond_expr, at gimple-isel.cc:281 at -O since r13-1085-g90467f0ad649d081 marxin at gcc dot gnu.org
2023-01-03 15:57 ` jakub at gcc dot gnu.org
2023-01-03 16:16 ` jakub at gcc dot gnu.org
2023-01-03 16:35 ` jakub at gcc dot gnu.org
2023-01-03 16:40 ` jakub at gcc dot gnu.org
2023-01-04  9:55 ` cvs-commit at gcc dot gnu.org
2023-01-04  9:56 ` jakub at gcc dot gnu.org
2023-01-09 10:08 ` rguenth at gcc dot gnu.org
2023-02-10 17:45 ` cvs-commit at gcc dot gnu.org
2023-05-02 20:13 ` cvs-commit at gcc dot gnu.org
2023-05-03 15:20 ` cvs-commit at gcc dot gnu.org

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).