public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <apinski@marvell.com>
To: <gcc-patches@gcc.gnu.org>
Cc: Andrew Pinski <apinski@marvell.com>
Subject: [PATCH 1] Add alternative testcase of phi-opt-25.c that tests phiopt
Date: Mon, 24 Apr 2023 17:24:04 -0700	[thread overview]
Message-ID: <20230425002404.533283-1-apinski@marvell.com> (raw)

Right now phi-opt-25.c has tests like `a ? func(a) : CST`
but if we add the simplifications to match.pd, then phi-opt-25.c
will no longer be testing phiopt to make sure these get optimized.
So this adds an alternative version which is designed to test
phiopt.

Committed as obvious after testing the testcase to make sure it does not
fail on x86_64-linux-gnu.

Thanks,
Andrew Pinski

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/phi-opt-25a.c: New test.
---
 gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25a.c | 89 +++++++++++++++++++++
 1 file changed, 89 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25a.c

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25a.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25a.c
new file mode 100644
index 00000000000..faecac59ee7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25a.c
@@ -0,0 +1,89 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+unsigned short test_bswap16(unsigned short x)
+{
+  if (x)
+    return __builtin_bswap16(x);
+  return 0;
+}
+
+unsigned int test_bswap32(unsigned int x)
+{
+  if (x)
+    return __builtin_bswap32(x);
+  return 0;
+}
+
+unsigned long long test_bswap64(unsigned long long x)
+{
+  if (x)
+    return __builtin_bswap64(x);
+  return 0;
+}
+
+int test_clrsb(int x)
+{
+  if (x)
+    return __builtin_clrsb(x);
+  return (__SIZEOF_INT__*8-1);
+}
+
+int test_clrsbl(long x)
+{
+  if (x)
+    return __builtin_clrsbl(x);
+  return (__SIZEOF_LONG__*8-1);
+}
+
+int test_clrsbll(long long x)
+{
+  if (x)
+    return __builtin_clrsbll(x);
+  return (__SIZEOF_LONG_LONG__*8-1);
+}
+
+int test_parity(int x)
+{
+  if (x)
+    return __builtin_parity(x);
+  return 0;
+}
+
+int test_parityl(long x)
+{
+  if (x)
+    return __builtin_parityl(x);
+  return 0;
+}
+
+int test_parityll(long long x)
+{
+  if (x)
+    return __builtin_parityll(x);
+  return 0;
+}
+
+int test_popcount(int x)
+{
+  if (x)
+    return __builtin_popcount(x);
+  return 0;
+}
+
+int test_popcountl(long x)
+{
+  if (x)
+    return __builtin_popcountl(x);
+  return 0;
+}
+
+int test_popcountll(long long x)
+{
+  if (x)
+    return __builtin_popcountll(x);
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-not "goto" "optimized" } } */
+
-- 
2.31.1


                 reply	other threads:[~2023-04-25  0:24 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=20230425002404.533283-1-apinski@marvell.com \
    --to=apinski@marvell.com \
    --cc=gcc-patches@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: link
Be 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).