i386: Fix up *{add,sub}v<dwi>4_doubleword patterns (PR target/93412)
diff mbox series

Message ID 20200125235945.GI17695@tucnak
State New
Headers show
Series
  • i386: Fix up *{add,sub}v<dwi>4_doubleword patterns (PR target/93412)
Related show

Commit Message

Jakub Jelinek Jan. 25, 2020, 11:59 p.m. UTC
Hi!

In the *{add,sub}v<dwi>4_doubleword patterns, we don't really want to see a
VOIDmode last operand, because it then means invalid RTL
(sign_extend:{TI,POI} (const_int ...)) or so, and therefore something we
don't really handle in the splitter either.  We have
*{add,sub}v<dwi>4_doubleword_1 pattern for those and that is what combine
will match, the problem in this testcase is just that it was only RA that
propagated the constant into the instruction.

In the similar *{add,sub}v<mode>4 patterns, we make sure not to accept
VOIDmode operand and similarly to these have _1 suffixed variant that allows
constants.  Fixed thusly, bootstrapped/regtested on x86_64-linux and
i686-linux, ok for trunk?

2020-01-26  Jakub Jelinek  <jakub@redhat.com>

	PR target/93412
	* config/i386/i386.md (*addv<dwi>4_doubleword, *subv<dwi>4_doubleword):
	Use nonimmediate_operand instead of x86_64_hilo_general_operand and
	drop <di> from constraint of last operand.

	* gcc.dg/pr93412.c: New test.


	Jakub

Comments

Uros Bizjak Jan. 26, 2020, 9:22 a.m. UTC | #1
On Sun, Jan 26, 2020 at 12:59 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> In the *{add,sub}v<dwi>4_doubleword patterns, we don't really want to see a
> VOIDmode last operand, because it then means invalid RTL
> (sign_extend:{TI,POI} (const_int ...)) or so, and therefore something we
> don't really handle in the splitter either.  We have
> *{add,sub}v<dwi>4_doubleword_1 pattern for those and that is what combine
> will match, the problem in this testcase is just that it was only RA that
> propagated the constant into the instruction.
>
> In the similar *{add,sub}v<mode>4 patterns, we make sure not to accept
> VOIDmode operand and similarly to these have _1 suffixed variant that allows
> constants.  Fixed thusly, bootstrapped/regtested on x86_64-linux and
> i686-linux, ok for trunk?
>
> 2020-01-26  Jakub Jelinek  <jakub@redhat.com>
>
>         PR target/93412
>         * config/i386/i386.md (*addv<dwi>4_doubleword, *subv<dwi>4_doubleword):
>         Use nonimmediate_operand instead of x86_64_hilo_general_operand and
>         drop <di> from constraint of last operand.
>
>         * gcc.dg/pr93412.c: New test.

OK.

Thanks,
Uros.

> --- gcc/config/i386/i386.md.jj  2020-01-23 16:16:55.982005551 +0100
> +++ gcc/config/i386/i386.md     2020-01-25 19:30:20.358205644 +0100
> @@ -6135,7 +6135,7 @@ (define_insn_and_split "*addv<dwi>4_doub
>             (sign_extend:<QPWI>
>               (match_operand:<DWI> 1 "nonimmediate_operand" "%0,0"))
>             (sign_extend:<QPWI>
> -             (match_operand:<DWI> 2 "x86_64_hilo_general_operand" "r<di>,o")))
> +             (match_operand:<DWI> 2 "nonimmediate_operand" "r,o")))
>           (sign_extend:<QPWI>
>             (plus:<DWI> (match_dup 1) (match_dup 2)))))
>     (set (match_operand:<DWI> 0 "nonimmediate_operand" "=ro,r")
> @@ -6644,7 +6644,7 @@ (define_insn_and_split "*subv<dwi>4_doub
>             (sign_extend:<QPWI>
>               (match_operand:<DWI> 1 "nonimmediate_operand" "0,0"))
>             (sign_extend:<QPWI>
> -             (match_operand:<DWI> 2 "x86_64_hilo_general_operand" "r<di>,o")))
> +             (match_operand:<DWI> 2 "nonimmediate_operand" "r,o")))
>           (sign_extend:<QPWI>
>             (minus:<DWI> (match_dup 1) (match_dup 2)))))
>     (set (match_operand:<DWI> 0 "nonimmediate_operand" "=ro,r")
> --- gcc/testsuite/gcc.dg/pr93412.c.jj   2020-01-25 19:36:23.083680678 +0100
> +++ gcc/testsuite/gcc.dg/pr93412.c      2020-01-25 19:36:09.771883437 +0100
> @@ -0,0 +1,15 @@
> +/* PR target/93412 */
> +/* { dg-do compile { target int128 } } */
> +/* { dg-options "-Og" } */
> +
> +unsigned char a;
> +int b;
> +unsigned c;
> +
> +int
> +foo (int e, int f, int g, int h, int k, int i, short j)
> +{
> +  b = __builtin_add_overflow (a, 0, &c);
> +  b = __builtin_add_overflow_p (b, a, (unsigned __int128) 0) ? b : 0;
> +  return e + f + g + a + h + k + i + j + c;
> +}
>
>         Jakub
>

Patch
diff mbox series

--- gcc/config/i386/i386.md.jj	2020-01-23 16:16:55.982005551 +0100
+++ gcc/config/i386/i386.md	2020-01-25 19:30:20.358205644 +0100
@@ -6135,7 +6135,7 @@  (define_insn_and_split "*addv<dwi>4_doub
 	    (sign_extend:<QPWI>
 	      (match_operand:<DWI> 1 "nonimmediate_operand" "%0,0"))
 	    (sign_extend:<QPWI>
-	      (match_operand:<DWI> 2 "x86_64_hilo_general_operand" "r<di>,o")))
+	      (match_operand:<DWI> 2 "nonimmediate_operand" "r,o")))
 	  (sign_extend:<QPWI>
 	    (plus:<DWI> (match_dup 1) (match_dup 2)))))
    (set (match_operand:<DWI> 0 "nonimmediate_operand" "=ro,r")
@@ -6644,7 +6644,7 @@  (define_insn_and_split "*subv<dwi>4_doub
 	    (sign_extend:<QPWI>
 	      (match_operand:<DWI> 1 "nonimmediate_operand" "0,0"))
 	    (sign_extend:<QPWI>
-	      (match_operand:<DWI> 2 "x86_64_hilo_general_operand" "r<di>,o")))
+	      (match_operand:<DWI> 2 "nonimmediate_operand" "r,o")))
 	  (sign_extend:<QPWI>
 	    (minus:<DWI> (match_dup 1) (match_dup 2)))))
    (set (match_operand:<DWI> 0 "nonimmediate_operand" "=ro,r")
--- gcc/testsuite/gcc.dg/pr93412.c.jj	2020-01-25 19:36:23.083680678 +0100
+++ gcc/testsuite/gcc.dg/pr93412.c	2020-01-25 19:36:09.771883437 +0100
@@ -0,0 +1,15 @@ 
+/* PR target/93412 */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-Og" } */
+
+unsigned char a;
+int b;
+unsigned c;
+
+int
+foo (int e, int f, int g, int h, int k, int i, short j)
+{
+  b = __builtin_add_overflow (a, 0, &c);
+  b = __builtin_add_overflow_p (b, a, (unsigned __int128) 0) ? b : 0;
+  return e + f + g + a + h + k + i + j + c;
+}