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