aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorAndrew Pinski <quic_apinski@quicinc.com>2025-01-20 15:24:39 -0800
committerAndrew Pinski <quic_apinski@quicinc.com>2025-04-19 07:59:11 -0700
commit0939abea33ce9d9eb9328f80aace8109c096760c (patch)
tree5cb3c6cd30f12a50c4f81dec336755ff413792e8 /gcc/testsuite
parent05c4e3ecb54d22836ba2ae0ec1efedf8b78d7522 (diff)
downloadgcc-0939abea33ce9d9eb9328f80aace8109c096760c.zip
gcc-0939abea33ce9d9eb9328f80aace8109c096760c.tar.gz
gcc-0939abea33ce9d9eb9328f80aace8109c096760c.tar.bz2
combine: Better split point for `(and (not X))` [PR111949]
In a similar way find_split_point handles `a+b*C`, this adds the split point for `~a & b`. This allows for better instruction selection when the target has this instruction (aarch64, arm and x86_64 are examples which have this). Built and tested for aarch64-linux-gnu. PR rtl-optimization/111949 gcc/ChangeLog: * combine.cc (find_split_point): Add a split point for `(and (not X) Y)` if not in the outer set already. gcc/testsuite/ChangeLog: * gcc.target/aarch64/bic-1.c: New test. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/gcc.target/aarch64/bic-1.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/aarch64/bic-1.c b/gcc/testsuite/gcc.target/aarch64/bic-1.c
new file mode 100644
index 0000000..65e1514
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/bic-1.c
@@ -0,0 +1,40 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { check-function-bodies "**" "" "" } } */
+
+/* PR rtl-optmization/111949 */
+
+/*
+**func1:
+** bic w([0-9]+), w0, w1
+** and w0, w\1, 1
+** ret
+*/
+
+unsigned func1(unsigned a, bool b)
+{
+ int c = a & b;
+ return (c ^ a)&1;
+}
+
+/*
+**func2:
+** bic w([0-9]+), w1, w0
+** and w0, w\1, 255
+** ret
+*/
+unsigned func2(bool a, bool b)
+{
+ return ~a & b;
+}
+
+/*
+**func3:
+** bic w([0-9]+), w1, w0
+** and w0, w\1, 1
+** ret
+*/
+bool func3(bool a, unsigned char b)
+{
+ return !a & b;
+}