blob: b58df873191c0e9d1ad0971510dd68cf0d5686da [file] [log] [blame]
Brad Bishop26bdd442019-08-16 17:08:17 -04001From 64f1a238641616c9cca5823d7ca99e76a7c2a490 Mon Sep 17 00:00:00 2001
Brad Bishop286d45c2018-10-02 15:21:57 -04002From: Mahesh Bodapati <mbodapat@xilinx.com>
Brad Bishop26bdd442019-08-16 17:08:17 -04003Date: Thu, 12 Jan 2017 16:52:56 +0530
4Subject: [PATCH 12/54] [Patch, microblaze]: Added ashrsi3_with_size_opt Added
5 ashrsi3_with_size_opt pattern to optimize the sra instructions when the -Os
6 optimization is used. lshrsi3_with_size_opt is being removed as it has
7 conflicts with unsigned int variables
Brad Bishop286d45c2018-10-02 15:21:57 -04008
Brad Bishop26bdd442019-08-16 17:08:17 -04009Signed-off-by:Nagaraju Mekala <nmekala@xilix.com>
Brad Bishop286d45c2018-10-02 15:21:57 -040010---
11 gcc/config/microblaze/microblaze.md | 21 +++++++++++++++++++++
12 1 file changed, 21 insertions(+)
13
14diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
Brad Bishop26bdd442019-08-16 17:08:17 -040015index 93f5fa2..fe90a14 100644
Brad Bishop286d45c2018-10-02 15:21:57 -040016--- a/gcc/config/microblaze/microblaze.md
17+++ b/gcc/config/microblaze/microblaze.md
Brad Bishop26bdd442019-08-16 17:08:17 -040018@@ -1506,6 +1506,27 @@
Brad Bishop286d45c2018-10-02 15:21:57 -040019 (set_attr "length" "4,4")]
20 )
21
22+(define_insn "*ashrsi3_with_size_opt"
23+ [(set (match_operand:SI 0 "register_operand" "=&d")
24+ (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
25+ (match_operand:SI 2 "immediate_operand" "I")))]
26+ "(INTVAL (operands[2]) > 5 && optimize_size)"
27+ {
28+ operands[3] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
29+
30+ output_asm_insn ("ori\t%3,r0,%2", operands);
31+ if (REGNO (operands[0]) != REGNO (operands[1]))
32+ output_asm_insn ("addk\t%0,%1,r0", operands);
33+
34+ output_asm_insn ("addik\t%3,%3,-1", operands);
35+ output_asm_insn ("bneid\t%3,.-4", operands);
36+ return "sra\t%0,%0";
37+ }
38+ [(set_attr "type" "arith")
39+ (set_attr "mode" "SI")
40+ (set_attr "length" "20")]
41+)
42+
43 (define_insn "*ashrsi_inline"
44 [(set (match_operand:SI 0 "register_operand" "=&d")
45 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
46--
Brad Bishop26bdd442019-08-16 17:08:17 -0400472.7.4
Brad Bishop286d45c2018-10-02 15:21:57 -040048