[PATCH, i386]: Fix asm flag output to DImode for 32bit targets

Uros Bizjak ubizjak@gmail.com
Mon Jul 20 19:42:00 GMT 2015


2015-07-20  Uros Bizjak  <ubizjak@gmail.com>

    * config/i386/i386.c (ix86_md_asm_adjust): Handle DImode dest_mode
    for !TARGET_64BIT.

testsuite/ChangeLog:

2015-07-20  Uros Bizjak  <ubizjak@gmail.com>

    * gcc.target/i386/asm-flag-5.c (f_ll): New.

Bootstrapped and regression tested on x86_64-linux-gnu {,m32}.

Committed to mainline SVN.

Uros.
-------------- next part --------------
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 225982)
+++ config/i386/i386.c	(working copy)
@@ -45861,6 +45861,10 @@ ix86_md_asm_adjust (vec<rtx> &outputs, vec<rtx> &/
 	  error ("invalid type for asm flag output");
 	  continue;
 	}
+
+      if (dest_mode == DImode && !TARGET_64BIT)
+	dest_mode = SImode;
+
       if (dest_mode != QImode)
 	{
 	  rtx destqi = gen_reg_rtx (QImode);
@@ -45877,7 +45881,16 @@ ix86_md_asm_adjust (vec<rtx> &outputs, vec<rtx> &/
 	  else
 	    x = gen_rtx_ZERO_EXTEND (dest_mode, destqi);
 	}
-      emit_insn (gen_rtx_SET (dest, x));
+
+      if (dest_mode != GET_MODE (dest))
+	{
+	  rtx tmp = gen_reg_rtx (SImode);
+
+	  emit_insn (gen_rtx_SET (tmp, x));
+	  emit_insn (gen_zero_extendsidi2 (dest, tmp));
+	}
+      else
+	emit_insn (gen_rtx_SET (dest, x));
     }
   rtx_insn *seq = get_insns ();
   end_sequence ();
Index: testsuite/gcc.target/i386/asm-flag-5.c
===================================================================
--- testsuite/gcc.target/i386/asm-flag-5.c	(revision 225982)
+++ testsuite/gcc.target/i386/asm-flag-5.c	(working copy)
@@ -7,6 +7,7 @@ void f_c(void) { char x; asm("" : "=@ccc"(x)); }
 void f_s(void) { short x; asm("" : "=@ccc"(x)); }
 void f_i(void) { int x; asm("" : "=@ccc"(x)); }
 void f_l(void) { long x; asm("" : "=@ccc"(x)); }
+void f_ll(void) { long long x; asm("" : "=@ccc"(x)); }
 
 void f_f(void)
 {


More information about the Gcc-patches mailing list