From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EE6C6385829F; Sat, 15 Oct 2022 23:46:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE6C6385829F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665877604; bh=DNUjr/8CNNMS3jfgSIWbP/ls4YrZ2WF8GufTdcq3pcc=; h=From:To:Subject:Date:From; b=RgLq/2M7Ygv5zZ66fDmJmPUjKVpX2x/15bGhVzlIyrY9j96IulXFoeptLO8+Z0iTY TtB6mdGID9+QPl4nBG5p0pQNQ63n8kPefBAQNeKa55IfrhNbASVRfhC/SPodxoW5P+ Rgr7/1N+adfaYKmEoViw5gGcR2N64obA68pjRDn0= From: "law at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107275] New: [13 Regression] Recent ifcvt changes resulting in references to SSA_NAME on free list Date: Sat, 15 Oct 2022 23:46:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: law at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D107275 Bug ID: 107275 Summary: [13 Regression] Recent ifcvt changes resulting in references to SSA_NAME on free list Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: law at gcc dot gnu.org Target Milestone: --- This change: commit 25413fdb2ac24933214123e24ba165026452a6f2 (HEAD, refs/bisect/bad) Author: Andre Vieira Date: Tue Oct 11 10:49:27 2022 +0100 vect: Teach vectorizer how to handle bitfield accesses Is resulting in a PHI node with a dangling SSA_NAME. This in turn causes t= he compiler to abort when compiling the linux kernel on mips64-linux-gnu. If I put a breakpoint in exit, then go up the call chain enough we'll see t= hat we're calling verify_gimple_phi for this PHI: #8 0x00000000013a4bd4 in verify_gimple_phi (phi=3D0x7ffff77e5f00) at /home/jlaw/test/gcc/gcc/tree-cfg.cc:5201 5201 if (!useless_type_conversion_p (TREE_TYPE (phi_result), TREE_= TYPE (t))) (gdb) p debug_gimple_stmt (phi) .MEM_12 =3D PHI <_7(6), .MEM_4(D)(10)> Note the _7. And if we look at the actual underlying node: gdb) p debug_tree (t) nothrow def_stmt=20 version:7 in-free-list> ^^^^^^^^^^^^ If I put a breakpoint in ifcvt and look at the key block (#3) it looks like this: ;; basic block 3, loop depth 1 ;; pred: 6 ;; 5 # link_10 =3D PHI # .MEM_12 =3D PHI <.MEM_7(6), .MEM_4(D)(5)> # .MEM_6 =3D VDEF <.MEM_12> link_10->direct_complete =3D 0; # .MEM_7 =3D VDEF <.MEM_6> __asm__ __volatile__("" : : : "memory"); # VUSE <.MEM_7> link_8 =3D link_10->c_node.next; if (dev_5(D) !=3D link_8) goto ; [89.00%] else goto ; [11.00%] ;; succ: 6 ;; 4 ; Quite sensible. In particular note the reference to MEM_7 in the PHI. But when ifcvt is done: ;; basic block 3, loop depth 1 ;; pred: 6 ;; 10 # link_10 =3D PHI # .MEM_12 =3D PHI <_7(6), .MEM_4(D)(10)> # VUSE <.MEM_12> _ifc__16 =3D link_10->D.1530; _ifc__17 =3D BIT_INSERT_EXPR <_ifc__16, 0, 0 (1 bits)>; # VUSE <_7> link_8 =3D link_10->c_node.next; if (dev_5(D) !=3D link_8) goto ; [89.00%] else goto ; [11.00%] ;; succ: 6 ;; 4 Now it's in the free list, but there's still two references in bb3. Se se= emed to have removed the volatile asm which defined _7. I haven't dug any further than that. Testcase: struct list_head { struct list_head *next; }; struct device { struct list_head suppliers; }; struct device_link { struct list_head c_node; int direct_complete:1; }; void dpm_clear_superiors_direct_complete (struct device *dev) { struct device_link *link; for (; &link->c_node !=3D (&dev->suppliers);) { link->direct_complete =3D 0; __asm__ __volatile__ ("":::"memory"); link =3D link->c_node.next; } } Compile with -O2 -mabi=3D64 -I./ on mips64-linux-gnu.=