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] fix built in drem() and fmod() for !TARGET_USE_SAHF case


Martin Reinecke wrote:

I noticed a failure with mainline gcc on x86_64 which might be related to your patch.

Hello!


Attached to this message, please find a patch which fixes drem() and fmod() built-ins for !TARGET_USE_SAHF case. Attached patch is tested on i686-pc-linux-gnu, and should work for x86_64 architecture. This patch will use 'sahf' or 'testb $04, %ah', depending on preferred instruction for selected architecture.

For pentium4 and other 'x86_use_sahf' targets gcc now  generates:
       fprem1
       fnstsw  %ax
       sahf
       jp  .L11

For x86_64, K8 and other targers, gcc now generates:
       fprem1
       fnstsw  %ax
       testb   $4, %ah
       jne .L11

2004-05-07 Uros Bizjak <uros@kss-loka.si>

   * config/i386/i386.c (ix86_emit_fp_unordered_jump): Use
   testb $4, %ah insn instead of sahf insn if !TARGET_USE_SAHF.

Index: i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.666
diff -u -p -r1.666 i386.c
--- i386.c	7 May 2004 05:38:18 -0000	1.666
+++ i386.c	7 May 2004 12:23:16 -0000
@@ -15938,10 +15938,22 @@ ix86_emit_fp_unordered_jump (rtx label)
   rtx temp;
 
   emit_insn (gen_x86_fnstsw_1 (reg));
-  emit_insn (gen_x86_sahf_1 (reg));
+
+  if (TARGET_USE_SAHF)
+    {
+      emit_insn (gen_x86_sahf_1 (reg));
+
+      temp = gen_rtx_REG (CCmode, FLAGS_REG); 
+      temp = gen_rtx_UNORDERED (VOIDmode, temp, const0_rtx);
+    }
+  else
+    {
+      emit_insn (gen_testqi_ext_ccno_0 (reg, GEN_INT (0x04)));
+
+      temp = gen_rtx_REG (CCNOmode, FLAGS_REG); 
+      temp = gen_rtx_NE (VOIDmode, temp, const0_rtx);
+    }
   
-  temp = gen_rtx_REG (CCmode, FLAGS_REG); 
-  temp = gen_rtx_UNORDERED (VOIDmode, temp, const0_rtx);
   temp = gen_rtx_IF_THEN_ELSE (VOIDmode, temp,
 			      gen_rtx_LABEL_REF (VOIDmode, label),
 			      pc_rtx);

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