From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 23BC838460B2; Thu, 25 Apr 2024 13:28:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23BC838460B2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714051717; bh=D8QTxlfyojLtlErISluCPMfkxOOPOrtUuchRXabbzJo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EzMobLrzkoxGJ3qo+JkY8gnJxLUycE0YcD947FvkHk4r0OOUpXmbOZ5MxXPhxixKz fWUqlp5UFgpBNvYY4u/qD7kNFjrU2ZaTRyOGN1zb8dhvOGMJ4yDTHzwD8+RY2M8l9+ xHygQiGjbKDOP3kwdwzSn107D1iT1SPwRkyetTFQ= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/114734] [14] RISC-V rv64gcv_zvl256b miscompile with -flto -O3 -mrvv-vector-bits=zvl Date: Thu, 25 Apr 2024 13:28:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: needs-bisection, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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=3D114734 --- Comment #9 from Richard Biener --- (In reply to Robin Dapp from comment #8) > Created attachment 58037 [details] > Expand dump >=20 > Dump attached. Insn 209 is the problematic one. > The changing from _911 to 1078 happens in internal-fn.cc:expand_call_mem_= ref > (and not via TER). > The lookup there is simple and I was also wondering if there is some > single_imm_use or so missing. Nah, it's invalid to do that. You have to use get_gimple_for_ssa_name inst= ead and handle a NULL return. Alternatively the code could check for no SSA use on the def (to catch _1 =3D &a). So the error is in r8-6047-g65dd1346027bb5 which makes it a quite old wrong-code issue. And yes, Richard S. wrote that. Can you check if the following fixes the issue? (untested besides compiling it) diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc index 2c764441cde..0a7053c2286 100644 --- a/gcc/internal-fn.cc +++ b/gcc/internal-fn.cc @@ -53,6 +53,8 @@ along with GCC; see the file COPYING3. If not see #include "rtl-iter.h" #include "gimple-range.h" #include "fold-const-call.h" +#include "tree-ssa-live.h" +#include "tree-outof-ssa.h" /* For lang_hooks.types.type_for_mode. */ #include "langhooks.h" @@ -2964,8 +2966,8 @@ expand_call_mem_ref (tree type, gcall *stmt, int inde= x) tree tmp =3D addr; if (TREE_CODE (tmp) =3D=3D SSA_NAME) { - gimple *def =3D SSA_NAME_DEF_STMT (tmp); - if (gimple_assign_single_p (def)) + gimple *def =3D get_gimple_for_ssa_name (tmp); + if (def && gimple_assign_single_p (def)) tmp =3D gimple_assign_rhs1 (def); }=