public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-7250] tree-optimization/109573 - avoid ICEing on unexpected live def
Date: Wed, 26 Apr 2023 09:33:50 +0000 (GMT)	[thread overview]
Message-ID: <20230426093350.6E8F33858C53@sourceware.org> (raw)

https://gcc.gnu.org/g:263d1ed0484fc81d3f93e39cdd2f9eb0ce4d3e88

commit r13-7250-g263d1ed0484fc81d3f93e39cdd2f9eb0ce4d3e88
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Apr 21 12:57:17 2023 +0200

    tree-optimization/109573 - avoid ICEing on unexpected live def
    
    The following relaxes the assert in vectorizable_live_operation
    where we catch currently unhandled cases to also allow an
    intermediate copy as it happens here but also relax the assert
    to checking only.
    
            PR tree-optimization/109573
            * tree-vect-loop.cc (vectorizable_live_operation): Allow
            unhandled SSA copy as well.  Demote assert to checking only.
    
            * g++.dg/vect/pr109573.cc: New testcase.
    
    (cherry picked from commit cddfe6bc40b3dc0806e260bbfb4cac82d609a258)

Diff:
---
 gcc/testsuite/g++.dg/vect/pr109573.cc | 91 +++++++++++++++++++++++++++++++++++
 gcc/tree-vect-loop.cc                 |  7 +--
 2 files changed, 95 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/g++.dg/vect/pr109573.cc b/gcc/testsuite/g++.dg/vect/pr109573.cc
new file mode 100644
index 00000000000..d96f86f9579
--- /dev/null
+++ b/gcc/testsuite/g++.dg/vect/pr109573.cc
@@ -0,0 +1,91 @@
+// { dg-do compile }
+// { dg-require-effective-target c++20 }
+
+void *operator new(__SIZE_TYPE__, void *__p) { return __p; }
+template <typename _Head> struct _Head_base {
+  _Head _M_head_impl;
+};
+template <unsigned long, typename...> struct _Tuple_impl;
+template <unsigned long _Idx, typename _Head, typename... _Tail>
+struct _Tuple_impl<_Idx, _Head, _Tail...> : _Tuple_impl<_Idx + 1, _Tail...>,
+                                            _Head_base<_Head> {
+  template <typename _UHead, typename... _UTail>
+  _Tuple_impl(_UHead __head, _UTail... __tail)
+      : _Tuple_impl<_Idx + 1, _Tail...>(__tail...), _Head_base<_Head>(__head) {}
+};
+template <unsigned long _Idx, typename _Head> struct _Tuple_impl<_Idx, _Head> {
+  template <typename _UHead> _Tuple_impl(_UHead);
+};
+template <typename... _Elements> struct tuple : _Tuple_impl<0, _Elements...> {
+  template <typename... _UElements>
+  tuple(_UElements... __elements)
+      : _Tuple_impl<0, _Elements...>(__elements...) {}
+};
+unsigned long position_;
+struct Zone {
+  template <typename T, typename... Args> T *New(Args... args) {
+    return new (reinterpret_cast<void *>(position_)) T(args...);
+  }
+};
+struct Label {
+  int pos_;
+  int near_link_pos_;
+};
+enum Condition { below_equal };
+void bind(Label *);
+Zone *zone();
+unsigned long deopt_info_address();
+int MakeDeferredCode___trans_tmp_2, MakeDeferredCode___trans_tmp_3,
+    Prologue___trans_tmp_6, MakeDeferredCode___trans_tmp_1;
+struct MaglevAssembler {
+  template <typename Function, typename... Args>
+  void MakeDeferredCode(Function &&, Args &&...);
+  template <typename Function, typename... Args>
+  void JumpToDeferredIf(Condition, Function, Args... args) {
+    MakeDeferredCode(Function(), args...);
+  }
+  void Prologue();
+};
+struct ZoneLabelRef {
+  ZoneLabelRef(Zone *zone) : label_(zone->New<Label>()) {}
+  ZoneLabelRef(MaglevAssembler *) : ZoneLabelRef(zone()) {}
+  Label *operator*() { return label_; }
+  Label *label_;
+};
+template <typename Function>
+struct FunctionArgumentsTupleHelper
+    : FunctionArgumentsTupleHelper<decltype(&Function::operator())> {};
+template <typename C, typename R, typename... A>
+struct FunctionArgumentsTupleHelper<R (C::*)(A...) const> {
+  using Tuple = tuple<A...>;
+};
+template <typename> struct StripFirstTupleArg;
+template <typename T1, typename... T>
+struct StripFirstTupleArg<tuple<T1, T...>> {
+  using Stripped = tuple<T...>;
+};
+template <typename Function> struct DeferredCodeInfoImpl {
+  template <typename... InArgs>
+  DeferredCodeInfoImpl(int *, int, int, Function, InArgs... args)
+      : args(args...) {}
+  StripFirstTupleArg<
+      typename FunctionArgumentsTupleHelper<Function>::Tuple>::Stripped args;
+};
+template <typename Function, typename... Args>
+void MaglevAssembler::MakeDeferredCode(Function &&deferred_code_gen,
+                                       Args &&...args) {
+  zone()->New<DeferredCodeInfoImpl<Function>>(
+      &MakeDeferredCode___trans_tmp_1, MakeDeferredCode___trans_tmp_2,
+      MakeDeferredCode___trans_tmp_3, deferred_code_gen, args...);
+}
+void MaglevAssembler::Prologue() {
+  int *__trans_tmp_9;
+  ZoneLabelRef deferred_call_stack_guard_return(this);
+  __trans_tmp_9 = reinterpret_cast<int *>(deopt_info_address());
+  JumpToDeferredIf(
+      below_equal, [](MaglevAssembler, int *, ZoneLabelRef, int, int) {},
+      __trans_tmp_9, deferred_call_stack_guard_return, Prologue___trans_tmp_6,
+      0);
+  Label __trans_tmp_7 = **deferred_call_stack_guard_return;
+  bind(&__trans_tmp_7);
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index ba28214f09a..6ea0f21fd13 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -10114,9 +10114,10 @@ vectorizable_live_operation (vec_info *vinfo,
 						use_stmt))
 	      {
 		enum tree_code code = gimple_assign_rhs_code (use_stmt);
-		gcc_assert (code == CONSTRUCTOR
-			    || code == VIEW_CONVERT_EXPR
-			    || CONVERT_EXPR_CODE_P (code));
+		gcc_checking_assert (code == SSA_NAME
+				     || code == CONSTRUCTOR
+				     || code == VIEW_CONVERT_EXPR
+				     || CONVERT_EXPR_CODE_P (code));
 		if (dump_enabled_p ())
 		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
 				   "Using original scalar computation for "

                 reply	other threads:[~2023-04-26  9:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230426093350.6E8F33858C53@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).