public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hubicka at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-108990-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108990 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)) == 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)) == TYPE_PRECISION (TREE_TYPE (@1))) (cmp @0 (convert @1))))) So last conditional is false (32 and 64) In this adjusted testcase: #include <stdint.h> void f1(); void f2(); void foo (int a) { int *b = (int *)a; if (b == (void *)0) { f1 (); } } the unnecessary cast survives to forwprop while it chould be caught by cpp1
next reply other threads:[~2023-03-02 13:49 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-02 13:49 hubicka at gcc dot gnu.org [this message] 2023-03-02 23:21 ` [Bug middle-end/108990] " pinskia at gcc dot gnu.org 2023-03-03 8:21 ` rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-108990-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).