This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, i386]: Optimize TImode constant loads for x86_64


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.
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" } } */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]