public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102622] [12 Regression] Wrong code with -O3 for skylake-avx512 and icelake-server by r12-3903 Date: Fri, 08 Oct 2021 06:04:48 +0000 [thread overview] Message-ID: <bug-102622-4-iHVE8fqYYF@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-102622-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102622 --- Comment #15 from Andrew Pinski <pinskia at gcc dot gnu.org> --- here is the C testcase: static inline const unsigned *max1(const unsigned *t, const unsigned *t1) { return *t > *t1 ? t : t1; } int var_20 = 0; int var_22 = 0; short arr_32 [13]; char arr_45 [69]; void test(int a, unsigned b, const long long *c) __attribute__((noipa)); void test(int a, unsigned b, const long long *c) { for (short d = 0; d < 13; d++) { for (int e = 0; e < a; e += 3) var_20 = 0; unsigned t = (short)b; if (*max1(&b, &t)) { arr_32[d] = 0; var_22 = *c; } for (unsigned f = 0; f < 69; f += 4) arr_45[f] = 0; } } int main() { long long t = 42; test(-1, 1, &t); if (var_22 != 42) __builtin_abort(); return 0; } ---- CUT ----- Here is the patch which I tested and is working: diff --git a/gcc/match.pd b/gcc/match.pd index a9791ceb74a..4fd2a8c3ea9 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3950,10 +3950,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (integer_onep (@1)) (convert (convert:boolean_type_node @0))) /* a ? -1 : 0 -> -a. */ - (if (INTEGRAL_TYPE_P (type) && integer_all_onesp (@1)) + (if (INTEGRAL_TYPE_P (type) && integer_all_onesp (@1) + && TYPE_PRECISION (type) != 1) (negate (convert (convert:boolean_type_node @0)))) /* a ? powerof2cst : 0 -> a << (log2(powerof2cst)) */ - (if (INTEGRAL_TYPE_P (type) && integer_pow2p (@1)) + (if (INTEGRAL_TYPE_P (type) && integer_pow2p (@1) + && TYPE_PRECISION (type) != 1) (with { tree shift = build_int_cst (integer_type_node, tree_log2 (@1)); } @@ -3967,10 +3969,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (integer_onep (@2)) (convert (bit_xor (convert:boolean_type_node @0) { booltrue; } ))) /* a ? -1 : 0 -> -(!a). */ - (if (INTEGRAL_TYPE_P (type) && integer_all_onesp (@2)) + (if (INTEGRAL_TYPE_P (type) && integer_all_onesp (@2) + && TYPE_PRECISION (type) != 1) (negate (convert (bit_xor (convert:boolean_type_node @0) { booltrue; } )))) /* a ? powerof2cst : 0 -> (!a) << (log2(powerof2cst)) */ - (if (INTEGRAL_TYPE_P (type) && integer_pow2p (@2)) + (if (INTEGRAL_TYPE_P (type) && integer_pow2p (@2) + && TYPE_PRECISION (type) != 1) (with { tree shift = build_int_cst (integer_type_node, tree_log2 (@2)); }
next prev parent reply other threads:[~2021-10-08 6:04 UTC|newest] Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-05 19:37 [Bug tree-optimization/102622] New: Wrong code with -O3 for skylake-avx512 and icelake-server vsevolod.livinskij at frtk dot ru 2021-10-05 22:21 ` [Bug tree-optimization/102622] [12 Regression] " pinskia at gcc dot gnu.org 2021-10-05 22:36 ` pinskia at gcc dot gnu.org 2021-10-05 23:31 ` pinskia at gcc dot gnu.org 2021-10-06 7:23 ` [Bug tree-optimization/102622] [12 Regression] Wrong code with -O3 for skylake-avx512 and icelake-server by r12-3903 aldyh at gcc dot gnu.org 2021-10-06 8:42 ` rguenth at gcc dot gnu.org 2021-10-06 12:55 ` hjl.tools at gmail dot com 2021-10-06 13:04 ` hjl.tools at gmail dot com 2021-10-06 13:10 ` aldyh at gcc dot gnu.org 2021-10-06 13:12 ` aldyh at gcc dot gnu.org 2021-10-06 13:26 ` hjl.tools at gmail dot com 2021-10-06 14:19 ` aldyh at redhat dot com 2021-10-06 14:21 ` hjl.tools at gmail dot com 2021-10-07 16:07 ` aldyh at gcc dot gnu.org 2021-10-07 21:29 ` pinskia at gcc dot gnu.org 2021-10-07 21:31 ` pinskia at gcc dot gnu.org 2021-10-08 6:04 ` pinskia at gcc dot gnu.org [this message] 2021-10-09 22:25 ` pinskia at gcc dot gnu.org 2021-10-10 1:05 ` [Bug tree-optimization/102622] [9/10/12 Regression] Wrong code with -O1 and above due to phiopt and signed one bit integer types pinskia at gcc dot gnu.org 2021-10-10 1:54 ` pinskia at gcc dot gnu.org 2021-10-10 5:49 ` pinskia at gcc dot gnu.org 2021-10-10 9:04 ` cvs-commit at gcc dot gnu.org 2021-10-10 9:06 ` [Bug tree-optimization/102622] [9/10 " pinskia at gcc dot gnu.org 2021-10-10 9:18 ` pinskia at gcc dot gnu.org 2021-10-10 23:21 ` pinskia at gcc dot gnu.org 2021-10-11 9:22 ` cvs-commit at gcc dot gnu.org 2021-10-11 9:24 ` [Bug tree-optimization/102622] [9 " pinskia at gcc dot gnu.org 2021-10-11 21:07 ` cvs-commit at gcc dot gnu.org 2021-10-11 21:08 ` pinskia at gcc dot gnu.org 2021-10-11 21:19 ` cvs-commit at gcc dot gnu.org 2021-11-09 19:03 ` cvs-commit 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-102622-4-iHVE8fqYYF@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).