From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 314283858C52; Tue, 10 Jan 2023 09:40:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 314283858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673343653; bh=GUUGlEgwk0MH6SyQooNr5kXGRCOOFK2VjKvHIIjS6T0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HH2QpC5lFYjShco86tIxp6rTGjAmlQ8J7/77vmGUf0KKwv1oDIaIWBurbDFlFstlb 4/BTJDcJTREUAl7nPiKvtB2qqfeBmsE0xrTrVNI/sSpSbTBrCMr1a4TFWrh9I0ymU2 UIbyL3+ucyrpjT560sokaurKu35ZHCdrngqsNYOE= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108314] [13 Regression] Segfault in gimple-match-head.cc:do_valueize when vectorizing for SVE since r13-707-g68e0063397ba82 Date: Tue, 10 Jan 2023 09:40:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108314 --- Comment #3 from Richard Biener --- (gdb) p debug_gimple_stmt (stmt) t_5 =3D .FOLD_EXTRACT_LAST (t_14, _41, ); there's a missing call argument, the call is built here: #0 vectorizable_condition (vinfo=3D0x3b67200, stmt_info=3D0x3c3d160,=20 gsi=3D0x7fffffffcad0, vec_stmt=3D0x7fffffffc8a8, slp_node=3D0x0, cost_v= ec=3D0x0) at /home/rguenther/src/trunk/gcc/tree-vect-stmts.cc:10763 10763 new_stmt =3D gimple_build_call_internal (gdb) l 10758 gimple *new_stmt; 10759 if (reduction_type =3D=3D EXTRACT_LAST_REDUCTION) 10760 { 10761 gimple *old_stmt =3D vect_orig_stmt (stmt_info)->stmt; 10762 tree lhs =3D gimple_get_lhs (old_stmt); 10763 new_stmt =3D gimple_build_call_internal 10764 (IFN_FOLD_EXTRACT_LAST, 3, else_clause, vec_compare, 10765 vec_then_clause); 10766 gimple_call_set_lhs (new_stmt, lhs); 10767 SSA_NAME_DEF_STMT (lhs) =3D new_stmt; (gdb) p vec_then_clause $13 =3D which is because we run into else if (bitop2 =3D=3D BIT_NOT_EXPR) { /* Instead of doing ~x ? y : z do x ? z : y. */ vec_compare =3D new_temp; std::swap (vec_then_clause, vec_else_clause); but vec_else_clause isn't initialized for EXTRACT_LAST_REDUCTION. Instead we should swap with else_clause here? It seems to me I've seen this before ... Note that if we swap we fail to expand the internal function which seems to want the scalar/vector args in specific places and _not_ support this inversion. So instead avoid doing this optimization.=