Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 1 | From cf85f09a0fade1e7827828a3dc9a526c212f3be7 Mon Sep 17 00:00:00 2001 |
| 2 | From: Mahesh Bodapati <mbodapat@xilinx.com> |
| 3 | Date: Sat, 26 Aug 2017 19:21:39 -0700 |
| 4 | Subject: [PATCH] Inline Expansion of fsqrt builtin |
| 5 | |
| 6 | Inline Expansion of fsqrt builtin. The changes are made in the patch for |
| 7 | the inline expansion of the fsqrt builtin with fqrt instruction. The |
| 8 | sqrt math function takes double as argument and return double as |
| 9 | argument. The pattern is selected while expanding the unary op through |
| 10 | expand_unop which passes DFmode and the DFmode pattern was not there |
| 11 | returning zero. Thus the sqrt math function is not inlined and expanded. |
| 12 | The pattern with DFmode argument is added. Also the source and |
| 13 | destination argument is not same the DF through two different |
| 14 | consecutive registers with lower 32 bit is the argument passed to sqrt |
| 15 | and the higher 32 bit is zero. If the source and destinations are |
| 16 | different the DFmode 64 bits registers is not set properly giving the |
| 17 | problem in runtime. Such changes are taken care in the implementation of |
| 18 | the pattern for DFmode for inline expansion of the sqrt. |
| 19 | |
| 20 | ChangeLog: |
| 21 | |
| 22 | 2015-06-16 Ajit Agarwal <ajitkum@xilinx.com> |
| 23 | Nagaraju Mekala <nagaraju.mekala@xilinx.com> |
| 24 | |
| 25 | * config/microblaze/microblaze.md (sqrtdf2): New |
| 26 | pattern. |
| 27 | |
| 28 | Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com> |
| 29 | Signed-off-by: Ajit Agarwal <ajitkum@xilinx.com> |
| 30 | Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com> |
| 31 | Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com> |
| 32 | Upstream-Status: Pending |
| 33 | --- |
| 34 | gcc/config/microblaze/microblaze.md | 14 ++++++++++++++ |
| 35 | 1 file changed, 14 insertions(+) |
| 36 | |
| 37 | diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md |
| 38 | index a3954a24b6..13f8803428 100644 |
| 39 | --- a/gcc/config/microblaze/microblaze.md |
| 40 | +++ b/gcc/config/microblaze/microblaze.md |
| 41 | @@ -449,6 +449,20 @@ |
| 42 | (set_attr "mode" "SF") |
| 43 | (set_attr "length" "4")]) |
| 44 | |
| 45 | +(define_insn "sqrtdf2" |
| 46 | + [(set (match_operand:DF 0 "register_operand" "=d") |
| 47 | + (sqrt:DF (match_operand:DF 1 "register_operand" "dG")))] |
| 48 | + "TARGET_HARD_FLOAT && TARGET_FLOAT_SQRT" |
| 49 | + { |
| 50 | + if (REGNO (operands[0]) == REGNO (operands[1])) |
| 51 | + return "fsqrt\t%0,%1"; |
| 52 | + else |
| 53 | + return "fsqrt\t%0,%1\n\taddk\t%D0,%D1,r0"; |
| 54 | + } |
| 55 | + [(set_attr "type" "fsqrt") |
| 56 | + (set_attr "mode" "SF") |
| 57 | + (set_attr "length" "4")]) |
| 58 | + |
| 59 | (define_insn "fix_truncsfsi2" |
| 60 | [(set (match_operand:SI 0 "register_operand" "=d") |
| 61 | (fix:SI (match_operand:SF 1 "register_operand" "d")))] |
| 62 | -- |
| 63 | 2.14.2 |
| 64 | |