Jakub Jelinek <ja...@redhat.com> writes:
> Hi!
>
> uaddvdi4 expander has an optimization for the low 32-bits of the 2nd input
> operand known to be 0.  Unfortunately, in that case it only emits copying of
> the low 32 bits to the low 32 bits of the destination, but doesn't emit the
> addition with overflow detection for the high 64 bits.
> Well, to be precise, it emits it, but into an RTL sequence returned by
> gen_uaddvsi4, but that sequence isn't emitted anywhere.
>
> Fixed thusly, bootstrapped/regtested on armv7hl-linux-gnueabi, ok for trunk?
>
> 2020-01-30  Jakub Jelinek  <ja...@redhat.com>
>
>       PR target/93494
>       * config/arm/arm.md (uaddvdi4): Actually emit what gen_uaddvsi4
>       returned.
>
>       * gcc.c-torture/execute/pr93494.c: New test.

OK, thanks.

Richard

>
> --- gcc/config/arm/arm.md.jj  2020-01-18 09:39:51.614204056 +0100
> +++ gcc/config/arm/arm.md     2020-01-29 19:56:15.700835823 +0100
> @@ -721,7 +721,7 @@ (define_expand "uaddvdi4"
>        if (!arm_add_operand (hi_op2, SImode))
>       hi_op2 = force_reg (SImode, hi_op2);
>  
> -      gen_uaddvsi4 (hi_result, hi_op1, hi_op2, operands[3]);
> +      emit_insn (gen_uaddvsi4 (hi_result, hi_op1, hi_op2, operands[3]));
>      }
>    else
>      {
> --- gcc/testsuite/gcc.c-torture/execute/pr93494.c.jj  2020-01-29 
> 20:01:26.849233488 +0100
> +++ gcc/testsuite/gcc.c-torture/execute/pr93494.c     2020-01-29 
> 20:00:59.391639624 +0100
> @@ -0,0 +1,13 @@
> +/* PR target/93494 */
> +
> +unsigned short a;
> +
> +int
> +main ()
> +{
> +  register unsigned long long y = 0;
> +  int x = __builtin_add_overflow (y, 0ULL, &a);
> +  if (x || a)
> +    __builtin_abort ();
> +  return 0;
> +}
>
>       Jakub

Reply via email to