From 623ae2ee3fced44b4ececd720155910db658f2d9 Mon Sep 17 00:00:00 2001 From: ibolton Date: Thu, 2 May 2013 12:52:22 +0000 Subject: [PATCH] AArch64 Support for BICS in the backend git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198526 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 8 +++ gcc/config/aarch64/aarch64.md | 66 ++++++++++++++++++ gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/gcc.target/aarch64/bics_1.c | 107 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/aarch64/bics_2.c | 111 ++++++++++++++++++++++++++++++ 5 files changed, 297 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/bics_1.c create mode 100644 gcc/testsuite/gcc.target/aarch64/bics_2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2acb274..f1692c6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2013-05-02 Ian Bolton + + * config/aarch64/aarch64.md (*and_one_cmpl3_compare0): + New pattern. + (*and_one_cmplsi3_compare0_uxtw): Likewise. + (*and_one_cmpl_3_compare0): Likewise. + (*and_one_cmpl_si3_compare0_uxtw): Likewise. + 2013-05-02 Richard Biener * tree-scalar-evolution.c (scev_info_hasher): Remove. diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 96be7a1..50acdaa 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -2746,6 +2746,35 @@ [(set_attr "v8type" "logic") (set_attr "mode" "")]) +(define_insn "*and_one_cmpl3_compare0" + [(set (reg:CC_NZ CC_REGNUM) + (compare:CC_NZ + (and:GPI (not:GPI + (match_operand:GPI 1 "register_operand" "r")) + (match_operand:GPI 2 "register_operand" "r")) + (const_int 0))) + (set (match_operand:GPI 0 "register_operand" "=r") + (and:GPI (not:GPI (match_dup 1)) (match_dup 2)))] + "" + "bics\\t%0, %2, %1" + [(set_attr "v8type" "logics") + (set_attr "mode" "")]) + +;; zero_extend version of above +(define_insn "*and_one_cmplsi3_compare0_uxtw" + [(set (reg:CC_NZ CC_REGNUM) + (compare:CC_NZ + (and:SI (not:SI + (match_operand:SI 1 "register_operand" "r")) + (match_operand:SI 2 "register_operand" "r")) + (const_int 0))) + (set (match_operand:DI 0 "register_operand" "=r") + (zero_extend:DI (and:SI (not:SI (match_dup 1)) (match_dup 2))))] + "" + "bics\\t%w0, %w2, %w1" + [(set_attr "v8type" "logics") + (set_attr "mode" "SI")]) + (define_insn "*_one_cmpl_3" [(set (match_operand:GPI 0 "register_operand" "=r") (LOGICAL:GPI (not:GPI @@ -2758,6 +2787,43 @@ [(set_attr "v8type" "logic_shift") (set_attr "mode" "")]) +(define_insn "*and_one_cmpl_3_compare0" + [(set (reg:CC_NZ CC_REGNUM) + (compare:CC_NZ + (and:GPI (not:GPI + (SHIFT:GPI + (match_operand:GPI 1 "register_operand" "r") + (match_operand:QI 2 "aarch64_shift_imm_" "n"))) + (match_operand:GPI 3 "register_operand" "r")) + (const_int 0))) + (set (match_operand:GPI 0 "register_operand" "=r") + (and:GPI (not:GPI + (SHIFT:GPI + (match_dup 1) (match_dup 2))) (match_dup 3)))] + "" + "bics\\t%0, %3, %1, %2" + [(set_attr "v8type" "logics_shift") + (set_attr "mode" "")]) + +;; zero_extend version of above +(define_insn "*and_one_cmpl_si3_compare0_uxtw" + [(set (reg:CC_NZ CC_REGNUM) + (compare:CC_NZ + (and:SI (not:SI + (SHIFT:SI + (match_operand:SI 1 "register_operand" "r") + (match_operand:QI 2 "aarch64_shift_imm_si" "n"))) + (match_operand:SI 3 "register_operand" "r")) + (const_int 0))) + (set (match_operand:DI 0 "register_operand" "=r") + (zero_extend:DI (and:SI + (not:SI + (SHIFT:SI (match_dup 1) (match_dup 2))) (match_dup 3))))] + "" + "bics\\t%w0, %w3, %w1, %2" + [(set_attr "v8type" "logics_shift") + (set_attr "mode" "SI")]) + (define_insn "clz2" [(set (match_operand:GPI 0 "register_operand" "=r") (clz:GPI (match_operand:GPI 1 "register_operand" "r")))] diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a083699..4c7a5b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-05-02 Ian Bolton + + * gcc.target/aarch64/bics_1.c: New test. + * gcc.target/aarch64/bics_2.c: Likewise. + 2013-05-02 Jakub Jelinek PR rtl-optimization/57131 diff --git a/gcc/testsuite/gcc.target/aarch64/bics_1.c b/gcc/testsuite/gcc.target/aarch64/bics_1.c new file mode 100644 index 0000000..d62ea9a --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/bics_1.c @@ -0,0 +1,107 @@ +/* { dg-do run } */ +/* { dg-options "-O2 --save-temps -fno-inline" } */ + +extern void abort (void); + +int +bics_si_test1 (int a, int b, int c) +{ + int d = a & ~b; + + /* { dg-final { scan-assembler-times "bics\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" 2 } } */ + if (d == 0) + return a + c; + else + return b + d + c; +} + +int +bics_si_test2 (int a, int b, int c) +{ + int d = a & ~(b << 3); + + /* { dg-final { scan-assembler "bics\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+, lsl 3" } } */ + if (d == 0) + return a + c; + else + return b + d + c; +} + +typedef long long s64; + +s64 +bics_di_test1 (s64 a, s64 b, s64 c) +{ + s64 d = a & ~b; + + /* { dg-final { scan-assembler-times "bics\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" 2 } } */ + if (d == 0) + return a + c; + else + return b + d + c; +} + +s64 +bics_di_test2 (s64 a, s64 b, s64 c) +{ + s64 d = a & ~(b << 3); + + /* { dg-final { scan-assembler "bics\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, lsl 3" } } */ + if (d == 0) + return a + c; + else + return b + d + c; +} + +int +main () +{ + int x; + s64 y; + + x = bics_si_test1 (29, ~4, 5); + if (x != ((29 & 4) + ~4 + 5)) + abort (); + + x = bics_si_test1 (5, ~2, 20); + if (x != 25) + abort (); + + x = bics_si_test2 (35, ~4, 5); + if (x != ((35 & ~(~4 << 3)) + ~4 + 5)) + abort (); + + x = bics_si_test2 (96, ~2, 20); + if (x != 116) + abort (); + + y = bics_di_test1 (0x130000029ll, + ~0x320000004ll, + 0x505050505ll); + + if (y != ((0x130000029ll & 0x320000004ll) + ~0x320000004ll + 0x505050505ll)) + abort (); + + y = bics_di_test1 (0x5000500050005ll, + ~0x2111211121112ll, + 0x0000000002020ll); + if (y != 0x5000500052025ll) + abort (); + + y = bics_di_test2 (0x130000029ll, + ~0x064000008ll, + 0x505050505ll); + if (y != ((0x130000029ll & ~(~0x064000008ll << 3)) + + ~0x064000008ll + 0x505050505ll)) + abort (); + + y = bics_di_test2 (0x130002900ll, + ~0x088000008ll, + 0x505050505ll); + if (y != (0x130002900ll + 0x505050505ll)) + abort (); + + return 0; +} + +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/bics_2.c b/gcc/testsuite/gcc.target/aarch64/bics_2.c new file mode 100644 index 0000000..e33c748 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/bics_2.c @@ -0,0 +1,111 @@ +/* { dg-do run } */ +/* { dg-options "-O2 --save-temps -fno-inline" } */ + +extern void abort (void); + +int +bics_si_test1 (int a, int b, int c) +{ + int d = a & ~b; + + /* { dg-final { scan-assembler-not "bics\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" } } */ + /* { dg-final { scan-assembler-times "bic\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" 2 } } */ + if (d <= 0) + return a + c; + else + return b + d + c; +} + +int +bics_si_test2 (int a, int b, int c) +{ + int d = a & ~(b << 3); + + /* { dg-final { scan-assembler-not "bics\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+, lsl 3" } } */ + /* { dg-final { scan-assembler "bic\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+, lsl 3" } } */ + if (d <= 0) + return a + c; + else + return b + d + c; +} + +typedef long long s64; + +s64 +bics_di_test1 (s64 a, s64 b, s64 c) +{ + s64 d = a & ~b; + + /* { dg-final { scan-assembler-not "bics\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" } } */ + /* { dg-final { scan-assembler-times "bic\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" 2 } } */ + if (d <= 0) + return a + c; + else + return b + d + c; +} + +s64 +bics_di_test2 (s64 a, s64 b, s64 c) +{ + s64 d = a & ~(b << 3); + + /* { dg-final { scan-assembler-not "bics\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, lsl 3" } } */ + /* { dg-final { scan-assembler "bic\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, lsl 3" } } */ + if (d <= 0) + return a + c; + else + return b + d + c; +} + +int +main () +{ + int x; + s64 y; + + x = bics_si_test1 (29, ~4, 5); + if (x != ((29 & 4) + ~4 + 5)) + abort (); + + x = bics_si_test1 (5, ~2, 20); + if (x != 25) + abort (); + + x = bics_si_test2 (35, ~4, 5); + if (x != ((35 & ~(~4 << 3)) + ~4 + 5)) + abort (); + + x = bics_si_test2 (96, ~2, 20); + if (x != 116) + abort (); + + y = bics_di_test1 (0x130000029ll, + ~0x320000004ll, + 0x505050505ll); + + if (y != ((0x130000029ll & 0x320000004ll) + ~0x320000004ll + 0x505050505ll)) + abort (); + + y = bics_di_test1 (0x5000500050005ll, + ~0x2111211121112ll, + 0x0000000002020ll); + if (y != 0x5000500052025ll) + abort (); + + y = bics_di_test2 (0x130000029ll, + ~0x064000008ll, + 0x505050505ll); + if (y != ((0x130000029ll & ~(~0x064000008ll << 3)) + + ~0x064000008ll + 0x505050505ll)) + abort (); + + y = bics_di_test2 (0x130002900ll, + ~0x088000008ll, + 0x505050505ll); + if (y != (0x130002900ll + 0x505050505ll)) + abort (); + + return 0; +} + +/* { dg-final { cleanup-saved-temps } } */ -- 2.7.4