public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7777] testsuite: Fix up sse2-v1ti-shift-3.c test [PR102986] Date: Wed, 23 Mar 2022 09:30:08 +0000 (GMT) [thread overview] Message-ID: <20220323093008.2A10D3858427@sourceware.org> (raw) https://gcc.gnu.org/g:4a9e92164a547afcf8cd3fc593c7660238ad2d59 commit r12-7777-g4a9e92164a547afcf8cd3fc593c7660238ad2d59 Author: Jakub Jelinek <jakub@redhat.com> Date: Wed Mar 23 10:29:37 2022 +0100 testsuite: Fix up sse2-v1ti-shift-3.c test [PR102986] This test is dg-do run and invokes UB when these rotate functions are called with 0 as second argument. There are some other tests that do this but they are dg-do compile only and not even call those functions at all, so it IMHO doesn't matter that they are only well defined for [1,127] and not [0,127]. The following patch fixes it, we pattern recognize both forms as rotates and we emit identical assembly. 2022-03-23 Jakub Jelinek <jakub@redhat.com> PR target/102986 * gcc.target/i386/sse2-v1ti-shift-3.c (rotr_v1ti, rotl_v1ti, rotr_ti, rotl_ti): Use -i&127 instead of 128-i to avoid UB on i == 0. Diff: --- gcc/testsuite/gcc.target/i386/sse2-v1ti-shift-3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gcc.target/i386/sse2-v1ti-shift-3.c b/gcc/testsuite/gcc.target/i386/sse2-v1ti-shift-3.c index 8d5c1227e3c..b4739d30da9 100644 --- a/gcc/testsuite/gcc.target/i386/sse2-v1ti-shift-3.c +++ b/gcc/testsuite/gcc.target/i386/sse2-v1ti-shift-3.c @@ -14,14 +14,14 @@ typedef __int128 ti; uv1ti ashl_v1ti(uv1ti x, unsigned int i) { return x << i; } uv1ti lshr_v1ti(uv1ti x, unsigned int i) { return x >> i; } sv1ti ashr_v1ti(sv1ti x, unsigned int i) { return x >> i; } -uv1ti rotr_v1ti(uv1ti x, unsigned int i) { return (x >> i) | (x << (128-i)); } -uv1ti rotl_v1ti(uv1ti x, unsigned int i) { return (x << i) | (x >> (128-i)); } +uv1ti rotr_v1ti(uv1ti x, unsigned int i) { return (x >> i) | (x << (-i&127)); } +uv1ti rotl_v1ti(uv1ti x, unsigned int i) { return (x << i) | (x >> (-i&127)); } uti ashl_ti(uti x, unsigned int i) { return x << i; } uti lshr_ti(uti x, unsigned int i) { return x >> i; } sti ashr_ti(sti x, unsigned int i) { return x >> i; } -uti rotr_ti(uti x, unsigned int i) { return (x >> i) | (x << (128-i)); } -uti rotl_ti(uti x, unsigned int i) { return (x << i) | (x >> (128-i)); } +uti rotr_ti(uti x, unsigned int i) { return (x >> i) | (x << (-i&127)); } +uti rotl_ti(uti x, unsigned int i) { return (x << i) | (x >> (-i&127)); } void test(ti x) {
reply other threads:[~2022-03-23 9:30 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220323093008.2A10D3858427@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@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).