This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix ICE on invalid inline asm with "X" constraint and non-zero CONST_VECTOR (PR inline-asm/84625)
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 2 Mar 2018 08:16:23 +0100
- Subject: Re: [PATCH] Fix ICE on invalid inline asm with "X" constraint and non-zero CONST_VECTOR (PR inline-asm/84625)
- Authentication-results: sourceware.org; auth=none
- References: <20180301231040.GU5867@tucnak>
On Fri, Mar 2, 2018 at 12:10 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> Assertions are only useful when inline asm is not involved, otherwise users
> can write anything they want.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
>
> 2018-03-02 Jakub Jelinek <jakub@redhat.com>
>
> PR inline-asm/84625
> * config/i386/i386.c (ix86_print_operand): Use conditional
> output_operand_lossage instead of gcc_assert if CONST_VECTOR is not
> zero vector.
>
> * gcc.target/i386/pr84625.c: New test.
OK.
Thanks,
Uros.
> --- gcc/config/i386/i386.c.jj 2018-02-26 20:49:57.345331383 +0100
> +++ gcc/config/i386/i386.c 2018-03-01 12:01:17.820587068 +0100
> @@ -18743,7 +18743,8 @@ ix86_print_operand (FILE *file, rtx x, i
> since we can in fact encode that into an immediate. */
> if (GET_CODE (x) == CONST_VECTOR)
> {
> - gcc_assert (x == CONST0_RTX (GET_MODE (x)));
> + if (x != CONST0_RTX (GET_MODE (x)))
> + output_operand_lossage ("invalid vector immediate");
> x = const0_rtx;
> }
>
> --- gcc/testsuite/gcc.target/i386/pr84625.c.jj 2018-03-01 12:00:06.254636914 +0100
> +++ gcc/testsuite/gcc.target/i386/pr84625.c 2018-03-01 12:14:54.044024998 +0100
> @@ -0,0 +1,12 @@
> +/* PR inline-asm/84625 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -msse2" } */
> +
> +typedef int V __attribute__((vector_size (16)));
> +
> +void
> +foo (void)
> +{
> + asm volatile ("# %0" : : "X" ((V) { 1, 2, 3, 4 })); // { dg-error "invalid vector immediate" }
> + asm volatile ("# %0" : : "" ((V) { 2, 3, 4, 5 })); // { dg-error "invalid vector immediate" }
> +}
>
> Jakub