This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR target/66813: gcc.target/i386/asm-flag-5.c failed with -march=pentium
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Richard Henderson <rth at redhat dot com>
- Date: Thu, 9 Jul 2015 15:15:54 +0200
- Subject: Re: [PATCH] PR target/66813: gcc.target/i386/asm-flag-5.c failed with -march=pentium
- Authentication-results: sourceware.org; auth=none
- References: <20150709131052 dot GA7254 at intel dot com>
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
>