diff options
author | Uros Bizjak <ubizjak@gmail.com> | 2017-08-21 17:15:07 +0200 |
---|---|---|
committer | Uros Bizjak <uros@gcc.gnu.org> | 2017-08-21 17:15:07 +0200 |
commit | 453773df32204ae524683b098444c2fa4ace8033 (patch) | |
tree | 3f9aa756b02d7fb4ed312861acd83d3be7bab864 /gcc/testsuite/gcc.target | |
parent | 2c0378f467abaa9190d52c3930ec4c825416f72f (diff) | |
download | gcc-453773df32204ae524683b098444c2fa4ace8033.zip gcc-453773df32204ae524683b098444c2fa4ace8033.tar.gz gcc-453773df32204ae524683b098444c2fa4ace8033.tar.bz2 |
re PR target/46091 (missed optimization: x86 bt/btc/bts instructions)
PR target/46091
* config/i386/i386.md (*btsq_imm): Rename from *btsq.
(*btrq_imm): Rename from *btrq.
(*btcq_imm): Rename from *btcq.
(btsc): New code attribute.
(*<btsc><mode>): New insn pattern.
(*btr<mode>): Ditto.
(*<btsc><mode>_mask): New insn_and_split pattern.
(*btr<mode>_mask): Ditto.
testsuite/ChangeLog:
PR target/46091
* gcc.target/i386/pr46091-4.c: New test.
* gcc.target/i386/pr46091-4a.c: Ditto.
* gcc.target/i386/pr46091-5.c: Ditto.
* gcc.target/i386/pr46091-5a.c: Ditto.
From-SVN: r251235
Diffstat (limited to 'gcc/testsuite/gcc.target')
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr46091-4.c | 29 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr46091-4a.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr46091-5.c | 29 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr46091-5a.c | 31 |
4 files changed, 120 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/i386/pr46091-4.c b/gcc/testsuite/gcc.target/i386/pr46091-4.c new file mode 100644 index 0000000..af2cfae --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr46091-4.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int test_1 (int x, int n) +{ + x &= ~(0x01 << n); + + return x; +} + +/* { dg-final { scan-assembler "btr" } } */ + +int test_2 (int x, int n) +{ + x |= (0x01 << n); + + return x; +} + +/* { dg-final { scan-assembler "bts" } } */ + +int test_3 (int x, int n) +{ + x ^= (0x01 << n); + + return x; +} + +/* { dg-final { scan-assembler "btc" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr46091-4a.c b/gcc/testsuite/gcc.target/i386/pr46091-4a.c new file mode 100644 index 0000000..5874aee --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr46091-4a.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int test_1 (int x, int n) +{ + n &= 0x1f; + + x &= ~(0x01 << n); + + return x; +} + +int test_2 (int x, int n) +{ + n &= 0x1f; + + x |= (0x01 << n); + + return x; +} + +int test_3 (int x, int n) +{ + n &= 0x1f; + + x ^= (0x01 << n); + + return x; +} + +/* { dg-final { scan-assembler-not "and\[lq\]\[ \t\]" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr46091-5.c b/gcc/testsuite/gcc.target/i386/pr46091-5.c new file mode 100644 index 0000000..3017029 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr46091-5.c @@ -0,0 +1,29 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2" } */ + +long test_1 (long x, int n) +{ + x &= ~((long)0x01 << n); + + return x; +} + +/* { dg-final { scan-assembler "btr" } } */ + +long test_2 (long x, int n) +{ + x |= ((long)0x01 << n); + + return x; +} + +/* { dg-final { scan-assembler "bts" } } */ + +long test_3 (long x, int n) +{ + x ^= ((long)0x01 << n); + + return x; +} + +/* { dg-final { scan-assembler "btc" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr46091-5a.c b/gcc/testsuite/gcc.target/i386/pr46091-5a.c new file mode 100644 index 0000000..0fa2d9b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr46091-5a.c @@ -0,0 +1,31 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2" } */ + +long test_1 (long x, int n) +{ + n &= 0x3f; + + x &= ~((long)0x01 << n); + + return x; +} + +long test_2 (long x, int n) +{ + n &= 0x3f; + + x |= ((long)0x01 << n); + + return x; +} + +long test_3 (long x, int n) +{ + n &= 0x3f; + + x ^= ((long)0x01 << n); + + return x; +} + +/* { dg-final { scan-assembler-not "and\[lq\]\[ \t\]" } } */ |