From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8147B3858C53; Thu, 2 Mar 2023 13:49:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8147B3858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677764985; bh=cz6m+0kdeXvmmb+EO7kvqI2gy5J791UnrkhsGv9J2iw=; h=From:To:Subject:Date:From; b=jS2r8TwL9YX35IajnMYdUdauNe/2a5uzx+eSZqTOvDIgVLx48ZJD0q1M2QPrh51Zl Bc0ScPHx01sP5A4FP6SpryU9zgjM8UjrZKAVn3CduKKrzXPm1Uwf/AYly2yh0Ru+4k NbbPFE9WKEYhu0Xz9CNFPqzwiieMVkTKpVGM8W9Q= From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/108990] New: Too restrictive precision check in fold and simplify pattern for PR70920 Date: Thu, 02 Mar 2023 13:49:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka 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=3D108990 Bug ID: 108990 Summary: Too restrictive precision check in fold and simplify pattern for PR70920 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: hubicka at gcc dot gnu.org Target Milestone: --- While experimenting with a new gimple pass we noticed that pr70920.c is sensitive on order of substitutions made. If 0 is propagated first into if stmt, match and simplify fails to simplify the conditional since it compares pointer type 0 with integer converted to pointer type. TYPE_PRECISION of int is 32. (for cmp (ne eq) (simplify (cmp (convert @0) INTEGER_CST@1) (if (((POINTER_TYPE_P (TREE_TYPE (@0)) && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@0))) && INTEGRAL_TYPE_P (TREE_TYPE (@1)) /* Don't perform this optimization in GENERIC if @0 has reference type when sanitizing. See PR101210. */ && !(GENERIC && TREE_CODE (TREE_TYPE (@0)) =3D=3D REFERENCE_TYPE && (flag_sanitize & (SANITIZE_NULL | SANITIZE_ALIGNMENT)))) || (INTEGRAL_TYPE_P (TREE_TYPE (@0)) && POINTER_TYPE_P (TREE_TYPE (@1)) && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@1))))) && TYPE_PRECISION (TREE_TYPE (@0)) =3D=3D TYPE_PRECISION (TREE_TYPE = (@1))) (cmp @0 (convert @1))))) So last conditional is false (32 and 64) In this adjusted testcase: #include void f1(); void f2(); void foo (int a) { int *b =3D (int *)a; if (b =3D=3D (void *)0) { f1 (); } } the unnecessary cast survives to forwprop while it chould be caught by cpp1=