From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CE044384AB41; Wed, 8 May 2024 16:34:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE044384AB41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715186085; bh=WuMO8LkYKSvMzhqlw4rqsY8eU/z5hYOjTHPNS0NAh9o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=R388/cQArY5ZWvDULXrySitG0adhh2cf5li2iLK5ApYWJrCHBIWm+2C2lcal1rDQ0 Pe3+KbrfJQWUuAaimGaVPASH9aP8ERlTRNJ/OdH/efv4juZGQonFe68tQyX+TY6fQt sk38yLiAinC98P994B96gY9wl9YNB4wB8vmsgQoo= From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug bootstrap/114985] [15 regression] internal compiler error: in discriminator_fail during stage2 Date: Wed, 08 May 2024 16:34:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: bootstrap X-Bugzilla-Version: 15.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aldyh 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: everconfirmed cf_reconfirmed_on bug_status cc 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=3D114985 Aldy Hernandez changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2024-05-08 Status|UNCONFIRMED |NEW CC| |amacleod at redhat dot com, | |hubicka at gcc dot gnu.org, | |jamborm at gcc dot gnu.org --- Comment #4 from Aldy Hernandez --- Confirmed. Here is some background on tracking discriminator failures. The sanity check in the range_op dispatch code has noticed that it has an unsupported pointer range combination. This is the sanity check: bool range_op_handler::fold_range (vrange &r, tree type, const vrange &lh, const vrange &rh, relation_trio rel) const ... ... if (has_pointer_operand_p (r, lh, rh) && !m_operator->pointers_handled_p (DISPATCH_FOLD_RANGE, dispatch_kind (r, lh, rh))) discriminator_fail (r, lh, rh); The above code fails if the operator cannot handle the pointer combo it was passed, and the operator at hand is op_equal: (gdb) p *this $11 =3D {m_operator =3D 0x1463a590 } What's being attempted is a =3D =3D=3D as per= the somewhat cryptic error: DISCRIMINATOR FAIL. Dispatch =3D=3D=3D=3D> RO_PPP <=3D=3D=3D=3D This is because for operator_equal::fold_range(), we only handle INTEGER =3D POINTER OP_EQUAL POINTER. That is, the result must be an integer: bool operator_equal::pointers_handled_p (range_op_dispatch_type type, unsigned dispatch) const { switch (type) { case DISPATCH_FOLD_RANGE: return dispatch =3D=3D RO_IPP; ... ... } This all comes from ipa_value_range_from_jfunc() which is trying to calcula= te the equality of two pointer ranges and store the result in a pointer. I believe this is incorrect, as the result of equality should be a boolean_type_node, or at least an integer. This is where IPA is trying to call fold_range with the invalid combo: Value_Range op_res (vr_type); Value_Range res (vr_type); tree op =3D ipa_get_jf_pass_through_operand (jfunc); Value_Range op_vr (TREE_TYPE (op)); range_op_handler handler (operation); ipa_range_set_and_normalize (op_vr, op); if (!handler || !op_res.supports_type_p (vr_type) =3D> || !handler.fold_range (op_res, vr_type, srcvr, op_vr)) op_res.set_varying (vr_type); It is trying to call fold_range() with EQ_EXPR for two pointer operands, but storing the result in a pointer: (gdb) p operation $18 =3D EQ_EXPR (gdb) p debug(srcvr) [prange] union tree_node * * [0, +INF] MASK 0xfffffffffffffff8 VALUE 0x0 $14 =3D void (gdb) p debug(op_vr) [prange] union tree_node * * [0, 0] MASK 0x0 VALUE 0x0 $15 =3D void IMO op_res should have an integer type, but it is a pointer: (gdb) p debug_generic_stmt(vr_type) union tree_node * * ...causing op_res to be a pointer: (gdb) p debug(op_res) [prange] UNDEFINED If =3D OP_EQUAL is valid gimple, then we shou= ld change operator_equal::fold_range() to accept all pointer operands. If not, then we need to change the IPA pass. I would appreciate if an IL expert could opine here.=