Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 1 | From 27c27a8876152bac78059a1b2d5a6f0ac9b8cee2 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 2 | From: Mahesh Bodapati <mbodapat@xilinx.com> |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 3 | Date: Tue, 17 Jan 2017 15:23:57 +0530 |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 4 | Subject: [PATCH 17/58] [Patch, microblaze]: Add optimized lshrsi3 |
| 5 | |
| 6 | When barrel shifter is not present, the immediate value |
| 7 | is greater than #5 and optimization is -OS, the |
| 8 | compiler will generate shift operation using loop. |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 9 | |
| 10 | Changelog |
| 11 | |
| 12 | 2013-11-26 David Holsgrove <david.holsgrove@xilinx.com> |
| 13 | |
| 14 | * gcc/config/microblaze/microblaze.md: Add size optimized lshrsi3 insn |
| 15 | |
| 16 | ChangeLog/testsuite |
| 17 | |
| 18 | 2014-02-12 David Holsgrove <david.holsgrove@xilinx.com> |
| 19 | |
| 20 | * gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c: New test. |
| 21 | |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 22 | Signed-off-by:Nagaraju <nmekala@xilix.com> |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 23 | Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com> |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 24 | --- |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 25 | gcc/config/microblaze/microblaze.md | 21 +++++++++++++++++++ |
| 26 | .../microblaze/others/lshrsi_Os_1.c | 13 ++++++++++++ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 27 | 2 files changed, 34 insertions(+) |
| 28 | create mode 100644 gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c |
| 29 | |
| 30 | diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 31 | index 187ad522dcc..8f9baec826b 100644 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 32 | --- a/gcc/config/microblaze/microblaze.md |
| 33 | +++ b/gcc/config/microblaze/microblaze.md |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 34 | @@ -1618,6 +1618,27 @@ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 35 | (set_attr "length" "4,4")] |
| 36 | ) |
| 37 | |
| 38 | +(define_insn "*lshrsi3_with_size_opt" |
| 39 | + [(set (match_operand:SI 0 "register_operand" "=&d") |
| 40 | + (lshiftrt:SI (match_operand:SI 1 "register_operand" "d") |
| 41 | + (match_operand:SI 2 "immediate_operand" "I")))] |
| 42 | + "(INTVAL (operands[2]) > 5 && optimize_size)" |
| 43 | + { |
| 44 | + operands[3] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM); |
| 45 | + |
| 46 | + output_asm_insn ("ori\t%3,r0,%2", operands); |
| 47 | + if (REGNO (operands[0]) != REGNO (operands[1])) |
| 48 | + output_asm_insn ("addk\t%0,%1,r0", operands); |
| 49 | + |
| 50 | + output_asm_insn ("addik\t%3,%3,-1", operands); |
| 51 | + output_asm_insn ("bneid\t%3,.-4", operands); |
| 52 | + return "srl\t%0,%0"; |
| 53 | + } |
| 54 | + [(set_attr "type" "multi") |
| 55 | + (set_attr "mode" "SI") |
| 56 | + (set_attr "length" "20")] |
| 57 | +) |
| 58 | + |
| 59 | (define_insn "*lshrsi_inline" |
| 60 | [(set (match_operand:SI 0 "register_operand" "=&d") |
| 61 | (lshiftrt:SI (match_operand:SI 1 "register_operand" "d") |
| 62 | diff --git a/gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c b/gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c |
| 63 | new file mode 100644 |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 64 | index 00000000000..32a3be7c76a |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 65 | --- /dev/null |
| 66 | +++ b/gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c |
| 67 | @@ -0,0 +1,13 @@ |
| 68 | +/* { dg-options "-Os -mno-xl-barrel-shift" } */ |
| 69 | + |
| 70 | +void testfunc(void) |
| 71 | +{ |
| 72 | + unsigned volatile int z = 8192; |
| 73 | + z >>= 8; |
| 74 | +} |
| 75 | +/* { dg-final { scan-assembler-not "\bsrli" } } */ |
| 76 | +/* { dg-final { scan-assembler "\ori\tr18,r0" } } */ |
| 77 | +/* { dg-final { scan-assembler "addk\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0" } } */ |
| 78 | +/* { dg-final { scan-assembler "addik\tr18,r18,-1" } } */ |
| 79 | +/* { dg-final { scan-assembler "bneid\tr18,.-4" } } */ |
| 80 | +/* { dg-final { scan-assembler "\srl\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1])" } } */ |
| 81 | -- |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 82 | 2.17.1 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 83 | |