public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/107485] New: gcc-10 ICE with -fnon-call-exception
@ 2022-11-01  3:23 spop at gcc dot gnu.org
  2022-11-01  3:40 ` [Bug middle-end/107485] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: spop at gcc dot gnu.org @ 2022-11-01  3:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107485
           Summary: gcc-10 ICE with -fnon-call-exception
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: spop at gcc dot gnu.org
  Target Milestone: ---

On arm64-linux I see the following crash only on gcc-10.
I do not see the ICE on gcc-11, 12, and trunk. 

$ ~/gcc-10/bld/gcc/cc1plus -fnon-call-exceptions f.ii
[...]
f.ii:29:23: internal compiler error: Segmentation fault
   29 |   template <int> void x(double *, b, unsigned long *) { f(); }
      |                       ^
0x134e58b crash_signal
        ../../gcc/toplev.c:328
0x1639464 tree_vec_extract(gimple_stmt_iterator*, tree_node*, tree_node*,
tree_node*, tree_node*)
        ../../gcc/tree-vect-generic.c:140
0x163ca0f expand_vector_condition
        ../../gcc/tree-vect-generic.c:1044
0x164081f expand_vector_operations_1
        ../../gcc/tree-vect-generic.c:1988
0x16419f7 expand_vector_operations
        ../../gcc/tree-vect-generic.c:2240
0x1641b3f execute
        ../../gcc/tree-vect-generic.c:2284
[...]

$ cat f.ii
typedef long a;
typedef double b;
typedef struct {
  a c __attribute__((__vector_size__(32)));
  b d __attribute__((__vector_size__(32)));
} e;
__attribute__((__always_inline__)) b f() {
  e g, h, i;
  g.c = h.d < i.d;
}
class j {
  bool k();
};
template <typename l, typename n, typename aa> void ab(aa, l, n) {
  int o;
  typename n::p q;
  unsigned long r;
  q(0, o, &r);
}
namespace s {
template <typename, typename n, typename, typename>
void t(j *, long, long, unsigned long *, int u) {
  n ac;
  void v();
  ab(v, u, ac);
}
} // namespace s
struct w {
  template <int> void x(double *, b, unsigned long *) { f(); }
  double ad;
  void operator()(double, double, unsigned long *) {
    unsigned long m;
    x<0>(&ad, 0, &m);
  }
};
using s::t;
struct y {
  using p = w;
};
long ag, ah;
unsigned long ai;
double aj;
bool j::k() {
  using n = y;
  t<j, n, a, double>(this, ag, ah, &ai, aj);
}



git bisect stops on this patch:

commit 1e676cfbe1e13fba2c636b560362ed4f0a56893d
Author: Richard Biener <rguenther@suse.de>
Date:   Mon May 18 08:51:23 2020 +0200

    middle-end/95171 - inlining of trapping compare into non-call EH fn

    This fixes always-inlining across -fnon-call-exception boundaries
    for conditions which we do not allow to throw.

    2020-05-18  Richard Biener  <rguenther@suse.de>

            PR middle-end/95171
            * tree-inline.c (remap_gimple_stmt): Split out trapping compares
            when inlining into a non-call EH function.

            * gcc.dg/pr95171.c: New testcase.

    (cherry picked from commit fe168751c5c1c517c7c89c9a1e4e561d66b24663)

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

* [Bug middle-end/107485] gcc-10 ICE with -fnon-call-exception
  2022-11-01  3:23 [Bug middle-end/107485] New: gcc-10 ICE with -fnon-call-exception spop at gcc dot gnu.org
@ 2022-11-01  3:40 ` pinskia at gcc dot gnu.org
  2022-11-01  3:41 ` [Bug middle-end/107485] [10 Regression] " pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-01  3:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Wait is broken on the GCC 10 branch? Or broken just for GCC 10.1.0?

Can you update known to work and known to fail? Because the patch for PR        
95171 is on the GCC 10 branch and was only included for GCC 10.3.0.

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

* [Bug middle-end/107485] [10 Regression] gcc-10 ICE with -fnon-call-exception
  2022-11-01  3:23 [Bug middle-end/107485] New: gcc-10 ICE with -fnon-call-exception spop at gcc dot gnu.org
  2022-11-01  3:40 ` [Bug middle-end/107485] " pinskia at gcc dot gnu.org
@ 2022-11-01  3:41 ` pinskia at gcc dot gnu.org
  2022-11-01  3:51 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-01  3:41 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
            Summary|gcc-10 ICE with             |[10 Regression] gcc-10 ICE
                   |-fnon-call-exception        |with -fnon-call-exception
   Last reconfirmed|                            |2022-11-01
   Target Milestone|---                         |10.5
      Known to fail|                            |10.3.0
      Known to work|                            |10.2.0
             Status|UNCONFIRMED                 |NEW
            Version|10.0                        |10.4.1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Never mind, I see 10.2.0 works but 10.3.0 fails.

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

* [Bug middle-end/107485] [10 Regression] gcc-10 ICE with -fnon-call-exception
  2022-11-01  3:23 [Bug middle-end/107485] New: gcc-10 ICE with -fnon-call-exception spop at gcc dot gnu.org
  2022-11-01  3:40 ` [Bug middle-end/107485] " pinskia at gcc dot gnu.org
  2022-11-01  3:41 ` [Bug middle-end/107485] [10 Regression] " pinskia at gcc dot gnu.org
@ 2022-11-01  3:51 ` pinskia at gcc dot gnu.org
  2022-11-01  3:56 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-01  3:51 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=104450

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect this is almost the same issue as reported in PR 104450 or very
similar.

The IR in GCC 10 before veclowering:
  _5 = _2 < _3;

  <bb 3> :
  _4 = VEC_COND_EXPR <_5, { -1, -1, -1, -1 }, { 0, 0, 0, 0 }>;

While the IR in GCC 11:
  _4 = _2 < _3;

  <bb 3> :
  _5 = _4;
  _6 = VEC_COND_EXPR <_5, { -1, -1, -1, -1 }, { 0, 0, 0, 0 }>;

Notice the extra assignment. It is just hiding the issue.

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

* [Bug middle-end/107485] [10 Regression] gcc-10 ICE with -fnon-call-exception
  2022-11-01  3:23 [Bug middle-end/107485] New: gcc-10 ICE with -fnon-call-exception spop at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-11-01  3:51 ` pinskia at gcc dot gnu.org
@ 2022-11-01  3:56 ` pinskia at gcc dot gnu.org
  2022-11-01  3:58 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-01  3:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Yes expand_vector_condition needs a similar fix just as PR 104450 did.

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

* [Bug middle-end/107485] [10 Regression] gcc-10 ICE with -fnon-call-exception
  2022-11-01  3:23 [Bug middle-end/107485] New: gcc-10 ICE with -fnon-call-exception spop at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-11-01  3:56 ` pinskia at gcc dot gnu.org
@ 2022-11-01  3:58 ` pinskia at gcc dot gnu.org
  2022-11-05 10:35 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-01  3:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> Yes expand_vector_condition needs a similar fix just as PR 104450 did.

Basically the bug is latent even on the trunk still.


Something like:
diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc
index 350129555a0..f585d3ddbc4 100644
--- a/gcc/tree-vect-generic.cc
+++ b/gcc/tree-vect-generic.cc
@@ -1044,6 +1044,7 @@ expand_vector_condition (gimple_stmt_iterator *gsi,
bitmap dce_ssa_names)
     {
       assign = dyn_cast<gassign *> (SSA_NAME_DEF_STMT (a));
       if (assign != NULL
+         && !stmt_can_throw_internal (cfun, assign)
          && TREE_CODE_CLASS (gimple_assign_rhs_code (assign)) ==
tcc_comparison)
        {
          a_is_comparison = true;


Should fix the issue ....

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

* [Bug middle-end/107485] [10 Regression] gcc-10 ICE with -fnon-call-exception
  2022-11-01  3:23 [Bug middle-end/107485] New: gcc-10 ICE with -fnon-call-exception spop at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-11-01  3:58 ` pinskia at gcc dot gnu.org
@ 2022-11-05 10:35 ` rguenth at gcc dot gnu.org
  2022-11-14 16:18 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-11-05 10:35 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
I will have a look.

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

* [Bug middle-end/107485] [10 Regression] gcc-10 ICE with -fnon-call-exception
  2022-11-01  3:23 [Bug middle-end/107485] New: gcc-10 ICE with -fnon-call-exception spop at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-11-05 10:35 ` rguenth at gcc dot gnu.org
@ 2022-11-14 16:18 ` rguenth at gcc dot gnu.org
  2022-11-14 18:08 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-11-14 16:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note that while this might be part of the solution we then still "wreck" EH
anyway by throwing it away instead of trying to replicate it for each component
compare.

So I'm not sure the proposed change is an improvement.  See the comment
in expand_vector_operations which says

          /* ???  If we do not cleanup EH then we will ICE in
             verification.  But in reality we have created wrong-code
             as we did not properly transition EH info and edges to
             the piecewise computations.  */
          if (maybe_clean_eh_stmt (gsi_stmt (gsi))
              && gimple_purge_dead_eh_edges (bb))
            cfg_changed = true;

that basically says we don't support -fnon-call-exceptions for generic
vector code.  Maybe it wouldn't be too difficult to do it correctly
but most definitely we don't do it.

Confirmed also on x86_64.

Note the issue in the PR is that we have a scalar condition with a
vector value.  That's not supposed to be a VEC_COND_EXPR, it's a
COND_EXPR!

Interestingly the scalar condition appears as part of inlining f(),
the code

      if (gassign *ass = dyn_cast <gassign *> (copy))
        if ((gimple_assign_rhs_code (ass) == COND_EXPR
             || gimple_assign_rhs_code (ass) == VEC_COND_EXPR)
            && gimple_could_trap_p (ass))
          {
            gassign *cmp
              = gimple_build_assign (make_ssa_name (boolean_type_node),
                                     gimple_assign_rhs1 (ass));
            gimple_seq_add_stmt (&stmts, cmp);
            gimple_assign_set_rhs1 (ass, gimple_assign_lhs (cmp));
          }

is wrong.

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

* [Bug middle-end/107485] [10 Regression] gcc-10 ICE with -fnon-call-exception
  2022-11-01  3:23 [Bug middle-end/107485] New: gcc-10 ICE with -fnon-call-exception spop at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-11-14 16:18 ` rguenth at gcc dot gnu.org
@ 2022-11-14 18:08 ` cvs-commit at gcc dot gnu.org
  2022-11-14 18:15 ` rguenth at gcc dot gnu.org
  2022-11-14 19:19 ` spop at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-14 18:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

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

commit r10-11083-gc17873d83aaeed037fb5d039df2e6303d4b6a553
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Nov 14 17:19:20 2022 +0100

    tree-optimization/107485 - fix non-call exception ICE with inlining

    Inlining performs a wrong non-call exception fixup for VEC_COND_EXPRs
    which on the branch fail to properly have the condition split out in
    the first place.

            PR tree-optimization/107485
            * tree-inline.c (remap_gimple_stmt): Use correct type for
            split out condition of [VEC_]COND_EXPRs.

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

* [Bug middle-end/107485] [10 Regression] gcc-10 ICE with -fnon-call-exception
  2022-11-01  3:23 [Bug middle-end/107485] New: gcc-10 ICE with -fnon-call-exception spop at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2022-11-14 18:08 ` cvs-commit at gcc dot gnu.org
@ 2022-11-14 18:15 ` rguenth at gcc dot gnu.org
  2022-11-14 19:19 ` spop at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-11-14 18:15 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

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

* [Bug middle-end/107485] [10 Regression] gcc-10 ICE with -fnon-call-exception
  2022-11-01  3:23 [Bug middle-end/107485] New: gcc-10 ICE with -fnon-call-exception spop at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2022-11-14 18:15 ` rguenth at gcc dot gnu.org
@ 2022-11-14 19:19 ` spop at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: spop at gcc dot gnu.org @ 2022-11-14 19:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Sebastian Pop <spop at gcc dot gnu.org> ---
Thanks Richard.
The patch fixed the larger test as well.

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

end of thread, other threads:[~2022-11-14 19:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-01  3:23 [Bug middle-end/107485] New: gcc-10 ICE with -fnon-call-exception spop at gcc dot gnu.org
2022-11-01  3:40 ` [Bug middle-end/107485] " pinskia at gcc dot gnu.org
2022-11-01  3:41 ` [Bug middle-end/107485] [10 Regression] " pinskia at gcc dot gnu.org
2022-11-01  3:51 ` pinskia at gcc dot gnu.org
2022-11-01  3:56 ` pinskia at gcc dot gnu.org
2022-11-01  3:58 ` pinskia at gcc dot gnu.org
2022-11-05 10:35 ` rguenth at gcc dot gnu.org
2022-11-14 16:18 ` rguenth at gcc dot gnu.org
2022-11-14 18:08 ` cvs-commit at gcc dot gnu.org
2022-11-14 18:15 ` rguenth at gcc dot gnu.org
2022-11-14 19:19 ` spop 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).