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