public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR target/66813: gcc.target/i386/asm-flag-5.c failed with -march=pentium
@ 2015-07-09 13:10 H.J. Lu
  2015-07-09 13:15 ` Uros Bizjak
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2015-07-09 13:10 UTC (permalink / raw)
  To: gcc-patches; +Cc: Uros Bizjak, Richard Henderson

gen_rtx_ZERO_EXTEND isn't suitable in ix86_md_asm_adjust since ZERO_EXTEND
may be expaned.  We should call gen_zero_extendqiXi2 instead.

OK for trunk?

H.J.
---
gcc/

	PR target/66813
	* config/i386/i386.c (ix86_md_asm_adjust): Replace
	gen_rtx_ZERO_EXTEND with gen_zero_extendqiXi2.

gcc/testsuite/

	PR target/66813
	* gcc.target/i386/asm-flag-6.c: New test.
---
 gcc/config/i386/i386.c                     | 16 +++++++++++++++-
 gcc/testsuite/gcc.target/i386/asm-flag-6.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-6.c

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 85e59a8..485638d 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -45845,7 +45845,21 @@ ix86_md_asm_adjust (vec<rtx> &outputs, vec<rtx> &/*inputs*/,
 	{
 	  rtx destqi = gen_reg_rtx (QImode);
 	  emit_insn (gen_rtx_SET (destqi, x));
-	  x = gen_rtx_ZERO_EXTEND (dest_mode, destqi);
+	  x = gen_reg_rtx (dest_mode);
+	  switch (dest_mode)
+	    {
+	    case HImode:
+	      emit_insn (gen_zero_extendqihi2 (x, destqi));
+	      break;
+	    case SImode:
+	      emit_insn (gen_zero_extendqisi2 (x, destqi));
+	      break;
+	    case DImode:
+	      emit_insn (gen_zero_extendqidi2 (x, destqi));
+	      break;
+	    default:
+	      gcc_unreachable ();
+	    }
 	}
       emit_insn (gen_rtx_SET (dest, x));
     }
diff --git a/gcc/testsuite/gcc.target/i386/asm-flag-6.c b/gcc/testsuite/gcc.target/i386/asm-flag-6.c
new file mode 100644
index 0000000..2c43227
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/asm-flag-6.c
@@ -0,0 +1,29 @@
+/* Test error conditions of asm flag outputs.  */
+/* { dg-do compile } */
+/* { dg-options "-mtune-ctrl=zero_extend_with_and " } */
+
+void f_B(void) { _Bool x; asm("" : "=@ccc"(x)); }
+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_f(void)
+{
+  float x;
+  asm("" : "=@ccc"(x)); /* { dg-error invalid type } */
+}
+
+void f_d(void)
+{
+  double x;
+  asm("" : "=@ccc"(x)); /* { dg-error invalid type } */
+}
+
+struct S { int x[3]; };
+
+void f_S(void)
+{
+  struct S x;
+  asm("" : "=@ccc"(x)); /* { dg-error invalid type } */
+}
-- 
2.4.3

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

* Re: [PATCH] PR target/66813: gcc.target/i386/asm-flag-5.c failed with -march=pentium
  2015-07-09 13:10 [PATCH] PR target/66813: gcc.target/i386/asm-flag-5.c failed with -march=pentium H.J. Lu
@ 2015-07-09 13:15 ` Uros Bizjak
  2015-07-10 10:08   ` Uros Bizjak
  0 siblings, 1 reply; 3+ messages in thread
From: Uros Bizjak @ 2015-07-09 13:15 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches, Richard Henderson

On Thu, Jul 9, 2015 at 3:10 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> gen_rtx_ZERO_EXTEND isn't suitable in ix86_md_asm_adjust since ZERO_EXTEND
> may be expaned.  We should call gen_zero_extendqiXi2 instead.
>
> OK for trunk?

No, your patch will clobber flags when multiple flag outputs are used.

(I plan to rewrite x86 zero_extend patterns to use preferred_for_size
attribute with peepholes, this will magically solve this bug and
readeflags-1.c failure).

Uros.

> H.J.
> ---
> gcc/
>
>         PR target/66813
>         * config/i386/i386.c (ix86_md_asm_adjust): Replace
>         gen_rtx_ZERO_EXTEND with gen_zero_extendqiXi2.
>
> gcc/testsuite/
>
>         PR target/66813
>         * gcc.target/i386/asm-flag-6.c: New test.
> ---
>  gcc/config/i386/i386.c                     | 16 +++++++++++++++-
>  gcc/testsuite/gcc.target/i386/asm-flag-6.c | 29 +++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-6.c
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 85e59a8..485638d 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -45845,7 +45845,21 @@ ix86_md_asm_adjust (vec<rtx> &outputs, vec<rtx> &/*inputs*/,
>         {
>           rtx destqi = gen_reg_rtx (QImode);
>           emit_insn (gen_rtx_SET (destqi, x));
> -         x = gen_rtx_ZERO_EXTEND (dest_mode, destqi);
> +         x = gen_reg_rtx (dest_mode);
> +         switch (dest_mode)
> +           {
> +           case HImode:
> +             emit_insn (gen_zero_extendqihi2 (x, destqi));
> +             break;
> +           case SImode:
> +             emit_insn (gen_zero_extendqisi2 (x, destqi));
> +             break;
> +           case DImode:
> +             emit_insn (gen_zero_extendqidi2 (x, destqi));
> +             break;
> +           default:
> +             gcc_unreachable ();
> +           }
>         }
>        emit_insn (gen_rtx_SET (dest, x));
>      }
> diff --git a/gcc/testsuite/gcc.target/i386/asm-flag-6.c b/gcc/testsuite/gcc.target/i386/asm-flag-6.c
> new file mode 100644
> index 0000000..2c43227
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/asm-flag-6.c
> @@ -0,0 +1,29 @@
> +/* Test error conditions of asm flag outputs.  */
> +/* { dg-do compile } */
> +/* { dg-options "-mtune-ctrl=zero_extend_with_and " } */
> +
> +void f_B(void) { _Bool x; asm("" : "=@ccc"(x)); }
> +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_f(void)
> +{
> +  float x;
> +  asm("" : "=@ccc"(x)); /* { dg-error invalid type } */
> +}
> +
> +void f_d(void)
> +{
> +  double x;
> +  asm("" : "=@ccc"(x)); /* { dg-error invalid type } */
> +}
> +
> +struct S { int x[3]; };
> +
> +void f_S(void)
> +{
> +  struct S x;
> +  asm("" : "=@ccc"(x)); /* { dg-error invalid type } */
> +}
> --
> 2.4.3
>

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

* Re: [PATCH] PR target/66813: gcc.target/i386/asm-flag-5.c failed with -march=pentium
  2015-07-09 13:15 ` Uros Bizjak
@ 2015-07-10 10:08   ` Uros Bizjak
  0 siblings, 0 replies; 3+ messages in thread
From: Uros Bizjak @ 2015-07-10 10:08 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches, Richard Henderson

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

On Thu, Jul 9, 2015 at 3:15 PM, Uros Bizjak <ubizjak@gmail.com> wrote:

>> gen_rtx_ZERO_EXTEND isn't suitable in ix86_md_asm_adjust since ZERO_EXTEND
>> may be expaned.  We should call gen_zero_extendqiXi2 instead.
>>
>> OK for trunk?
>
> No, your patch will clobber flags when multiple flag outputs are used.
>
> (I plan to rewrite x86 zero_extend patterns to use preferred_for_size
> attribute with peepholes, this will magically solve this bug and
> readeflags-1.c failure).

No, the above mentioned patch won't fly, it limits AND insn operands
too much with "q" constraint.

So, the patch below is what I plan to commit after
bootstrap/regression test on x86_64-linux-gnu {,-m32}.

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

    PR target/66813
    * config/i386/i386.c (ix86_md_asm_adjust): Emit movstrictqi
    sequence for TARGET_ZERO_EXTEND_WITH_AND targets.

testsuite/ChangeLog:

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

    PR target/66813
    * gcc.target/i386/pr66813.c: New test.

Uros.

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

Index: testsuite/gcc.target/i386/pr66813.c
===================================================================
--- testsuite/gcc.target/i386/pr66813.c	(revision 0)
+++ testsuite/gcc.target/i386/pr66813.c	(revision 0)
@@ -0,0 +1,4 @@
+/* { dg-do compile { target { ia32 } } } */
+/* { dg-options "-march=pentium" } */
+
+#include "asm-flag-5.c"
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 225648)
+++ config/i386/i386.c	(working copy)
@@ -45842,7 +45842,17 @@ ix86_md_asm_adjust (vec<rtx> &outputs, vec<rtx> &/
 	{
 	  rtx destqi = gen_reg_rtx (QImode);
 	  emit_insn (gen_rtx_SET (destqi, x));
-	  x = gen_rtx_ZERO_EXTEND (dest_mode, destqi);
+
+	  if (TARGET_ZERO_EXTEND_WITH_AND
+	      && optimize_function_for_speed_p (cfun))
+	    {
+	      x = force_reg (dest_mode, const0_rtx);
+
+	      emit_insn (gen_movstrictqi
+			 (gen_lowpart (QImode, x), destqi));
+	    }
+	  else
+	    x = gen_rtx_ZERO_EXTEND (dest_mode, destqi);
 	}
       emit_insn (gen_rtx_SET (dest, x));
     }

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

end of thread, other threads:[~2015-07-10 10:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-09 13:10 [PATCH] PR target/66813: gcc.target/i386/asm-flag-5.c failed with -march=pentium H.J. Lu
2015-07-09 13:15 ` Uros Bizjak
2015-07-10 10:08   ` 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).