public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "linkw at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/101596] New: vect_recog_mulhs_pattern could use incorrect precision to check shift count Date: Fri, 23 Jul 2021 07:50:07 +0000 [thread overview] Message-ID: <bug-101596-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101596 Bug ID: 101596 Summary: vect_recog_mulhs_pattern could use incorrect precision to check shift count Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: linkw at gcc dot gnu.org Target Milestone: --- I happened to spot this when I was working to add one new pattern for Power10 divide extended. Now vect_recog_mulhs_pattern uses target_precision to check the scale_term is expected or not, it's wrong when the precision of the actual used new_type larger than target_precision, since we use the new_type for the internal function call. Test case: ``` #define N 32 typedef signed long long sLL; signed int si_a[N], si_b[N]; signed short sh_c[N]; #define SH_CNT 48 //#define SH_CNT 32 __attribute__ ((noipa)) void test_ui () { for (int i = 0; i < N; i++) sh_c[i] = ((sLL) si_a[i] * (sLL) si_b[i]) >> SH_CNT; } __attribute__ ((optimize ("O0"))) int main () { for (int i = 0; i < N; i++) { si_a[i] = 0x12345678; si_b[i] = 0x76543210; } test_ui (); for (int i = 0; i < N; i++) { signed short exp = ((sLL) si_a[i] * (sLL) si_b[i]) >> SH_CNT; if (exp != sh_c[i]) __builtin_abort (); } return 0; } ``` gcc test.c -mcpu=power10 -O2 -ftree-vectorize $ ./a.out Aborted (core dumped) test.c:13:21: note: vect_recog_mulhs_pattern: detected: _6 = _5 >> 48;
next reply other threads:[~2021-07-23 7:50 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-23 7:50 linkw at gcc dot gnu.org [this message] 2021-07-23 7:51 ` [Bug middle-end/101596] " linkw at gcc dot gnu.org 2021-07-23 7:57 ` linkw at gcc dot gnu.org 2021-07-27 3:26 ` linkw at gcc dot gnu.org 2021-07-28 3:40 ` cvs-commit at gcc dot gnu.org 2021-07-28 3:49 ` linkw at gcc dot gnu.org 2021-08-25 2:40 ` pinskia 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-101596-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).