public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, i386]: Optimize TImode constant loads for x86_64
@ 2008-06-30 21:27 Uros Bizjak
  0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2008-06-30 21:27 UTC (permalink / raw)
  To: GCC Patches

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

Hello!

This patch optimizes TImode immediate operands to load directly from 
memory to XMM register, while still generating "movabsq" insn when 
loading immediate operand to TImode general register pair.

Currently, gcc compiles following test:

--cut here--
_Decimal128 test (void)
{
  return 1234123412341234.123412341234dl;
}
--cut here--

to (-O2):

test:
    movabsq    $4404704354742567410, %rax
    movabsq    $3470023512955869132, %rdx
    movq    %rax, -24(%rsp)
    movq    %rdx, -16(%rsp)
    movdqa    -24(%rsp), %xmm0
    ret

With attached patch, we generate:

test:
    movdqa    .LC0(%rip), %xmm0
    ret

OTOH, for these testcases:

--cut here--
_Decimal128 a;

void tt (void)
{
  a = 1234123412341234.123412341234dl;
}

__int128_t dd (int fd)
{
  __int128_t x = 120986749876238ll;

  return x + fd;
}
--cut here--

We still load constant to integer register pair:

tt:
    movabsq    $4404704354742567410, %rdx
    movabsq    $3470023512955869132, %rax
    movq    %rdx, a(%rip)
    movq    %rax, a+8(%rip)
    ret

dd:
    movslq    %edi,%rdi
    movabsq    $120986749876238, %rcx
    pushq    %rbx
    movq    %rdi, %rax
    movq    %rdi, %rdx
    xorl    %ebx, %ebx
    sarq    $63, %rdx
    addq    %rcx, %rax
    adcq    %rbx, %rdx
    popq    %rbx
    ret


2008-06-30 Uros Bizjak  <ubizjak@gmail.com>

    * config/i386/i386.md (*movti_rex64): Add "!" to "r" constraint
    of operand 0.

testsuite/ChangeLog:

2008-06-30 Uros Bizjak  <ubizjak@gmail.com>

    * gcc.target/i386/movti.c: New test.

Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu. 
Patch is committed to mainline.

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 992 bytes --]

Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md	(revision 137276)
+++ config/i386/i386.md	(working copy)
@@ -2464,7 +2464,7 @@
 	      (const_string "TI")))])
 
 (define_insn "*movti_rex64"
-  [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o,x,x,xm")
+  [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,xm")
 	(match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
   "TARGET_64BIT
    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
Index: testsuite/gcc.target/i386/movti.c
===================================================================
--- testsuite/gcc.target/i386/movti.c	(revision 0)
+++ testsuite/gcc.target/i386/movti.c	(revision 0)
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target dfp } */
+/* { dg-options "-O -std=gnu99" } */
+
+_Decimal128 test (void)
+{
+  return 1234123412341234.123412341234dl;
+}
+
+/* { dg-final { scan-assembler-not "movabs" } } */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-06-30 21:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-30 21:27 [PATCH, i386]: Optimize TImode constant loads for x86_64 Uros Bizjak

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).