public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [x86, PATCH] More effecient code for short unsigned conversion to float-point.
@ 2013-08-06 14:34 Yuri Rumyantsev
  2013-08-06 14:47 ` Andreas Schwab
  2013-08-06 21:03 ` Richard Henderson
  0 siblings, 2 replies; 3+ messages in thread
From: Yuri Rumyantsev @ 2013-08-06 14:34 UTC (permalink / raw)
  To: gcc-patches, Uros Bizjak, Igor Zamyatin, Areg Melik-Adamyan

[-- Attachment #1: Type: text/plain, Size: 448 bytes --]

Hi All,

Here is simple fix which produces more optimal code unsigned
char(short) to float(double) with direct rtl-generation.

Bootstrapping and regression testing were successful for x86-64.

Is it OK for trunk?

ChangeLog:

2013-08-06  Yuri Rumyantsev  <ysrumyan@gmail.com>

* config/i386/i386.md (floatunssi<mode>2 expand): Add support
for QI/HImode operand to produce more effecient code for
unsigned char(short) --> float(double) conversion.

[-- Attachment #2: i386-short-uns-conversion-to-fp.patch --]
[-- Type: application/octet-stream, Size: 1612 bytes --]

Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md	(revision 201475)
+++ config/i386/i386.md	(working copy)
@@ -5089,25 +5089,32 @@
   operands[3] = simplify_gen_subreg (DImode, operands[3], SImode, 0);
 })
 
-(define_expand "floatunssi<mode>2"
+(define_expand "floatuns<SWI124:mode><X87MODEF:mode>2"
   [(parallel
      [(set (match_operand:X87MODEF 0 "register_operand")
 	   (unsigned_float:X87MODEF
-	     (match_operand:SI 1 "nonimmediate_operand")))
+	     (match_operand:SWI124 1 "nonimmediate_operand")))
       (clobber (match_dup 2))
       (clobber (match_scratch:SI 3))])]
   "!TARGET_64BIT
    && ((TARGET_80387 && X87_ENABLE_FLOAT (<X87MODEF:MODE>mode, DImode)
 	&& TARGET_SSE)
-       || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH))"
+       || (SSE_FLOAT_MODE_P (<X87MODEF:MODE>mode) && TARGET_SSE_MATH))"
 {
-  if (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
+  if (GET_MODE_SIZE (<SWI124:MODE>mode) < GET_MODE_SIZE (SImode))
+    { 
+      operands[1] = convert_to_mode (SImode, operands[1], 1);
+      emit_insn (gen_floatsi<X87MODEF:mode>2 (operands[0], operands[1]));
+      DONE;
+    }
+  
+  if (SSE_FLOAT_MODE_P (<X87MODEF:MODE>mode) && TARGET_SSE_MATH)
     {
-      ix86_expand_convert_uns_si<mode>_sse (operands[0], operands[1]);
+      ix86_expand_convert_uns_si<X87MODEF:mode>_sse (operands[0], operands[1]);
       DONE;
     }
-  else
-    operands[2] = assign_386_stack_local (DImode, SLOT_TEMP);
+
+  operands[2] = assign_386_stack_local (DImode, SLOT_TEMP);
 })
 
 (define_expand "floatunsdisf2"

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [x86, PATCH] More effecient code for short unsigned conversion to float-point.
  2013-08-06 14:34 [x86, PATCH] More effecient code for short unsigned conversion to float-point Yuri Rumyantsev
@ 2013-08-06 14:47 ` Andreas Schwab
  2013-08-06 21:03 ` Richard Henderson
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2013-08-06 14:47 UTC (permalink / raw)
  To: Yuri Rumyantsev
  Cc: gcc-patches, Uros Bizjak, Igor Zamyatin, Areg Melik-Adamyan

Yuri Rumyantsev <ysrumyan@gmail.com> writes:

> * config/i386/i386.md (floatunssi<mode>2 expand): Add support
> for QI/HImode operand to produce more effecient code for

s/effecient/efficient/

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [x86, PATCH] More effecient code for short unsigned conversion to float-point.
  2013-08-06 14:34 [x86, PATCH] More effecient code for short unsigned conversion to float-point Yuri Rumyantsev
  2013-08-06 14:47 ` Andreas Schwab
@ 2013-08-06 21:03 ` Richard Henderson
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2013-08-06 21:03 UTC (permalink / raw)
  To: Yuri Rumyantsev
  Cc: gcc-patches, Uros Bizjak, Igor Zamyatin, Areg Melik-Adamyan

On 08/06/2013 04:33 AM, Yuri Rumyantsev wrote:
> -(define_expand "floatunssi<mode>2"
> +(define_expand "floatuns<SWI124:mode><X87MODEF:mode>2"
>    [(parallel
>       [(set (match_operand:X87MODEF 0 "register_operand")
>  	   (unsigned_float:X87MODEF
> -	     (match_operand:SI 1 "nonimmediate_operand")))
> +	     (match_operand:SWI124 1 "nonimmediate_operand")))
>        (clobber (match_dup 2))
>        (clobber (match_scratch:SI 3))])]
>    "!TARGET_64BIT
>     && ((TARGET_80387 && X87_ENABLE_FLOAT (<X87MODEF:MODE>mode, DImode)
>  	&& TARGET_SSE)
> -       || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH))"
> +       || (SSE_FLOAT_MODE_P (<X87MODEF:MODE>mode) && TARGET_SSE_MATH))"
>  {
> -  if (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
> +  if (GET_MODE_SIZE (<SWI124:MODE>mode) < GET_MODE_SIZE (SImode))
> +    { 
> +      operands[1] = convert_to_mode (SImode, operands[1], 1);
> +      emit_insn (gen_floatsi<X87MODEF:mode>2 (operands[0], operands[1]));
> +      DONE;
> +    }
> +  

The idea is correct, but there's no need to share the same expand,
adding a runtime test against the mode.


r~

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-08-06 21:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-06 14:34 [x86, PATCH] More effecient code for short unsigned conversion to float-point Yuri Rumyantsev
2013-08-06 14:47 ` Andreas Schwab
2013-08-06 21:03 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).