diff mbox series

[i386] : Fix PR 91385, Zero-extended negation is not generated

Message ID CAFULd4ar4aGmXp1owMU2V0ivM+M_O5G5+zfmi_4kJNxtLYYJug@mail.gmail.com
State New
Headers show
Series [i386] : Fix PR 91385, Zero-extended negation is not generated | expand

Commit Message

Uros Bizjak Aug. 7, 2019, 6:37 p.m. UTC
It looks that combine lost some of its unwanted creativity. Added
testcase will keep it that way.

2019-08-07  Uroš Bizjak  <ubizjak@gmail.com>

    PR target/91385
    * config/i386/sse.md (*negsi2_1_zext): Simplify insn pattern.
    (*negsi2_cmpz_zext): Ditto.

testsuite/ChangeLog:

2019-08-07  Uroš Bizjak  <ubizjak@gmail.com>

    PR target/91385
    * gcc.target/i386/pr91385.c: New test.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN.

Uros.

Comments

Segher Boessenkool Aug. 7, 2019, 10:17 p.m. UTC | #1
On Wed, Aug 07, 2019 at 08:37:52PM +0200, Uros Bizjak wrote:
> It looks that combine lost some of its unwanted creativity. Added
> testcase will keep it that way.

Huh, I wonder why it ever did that :-)  Strange.

> -;; Combine is quite creative about this pattern.
>  (define_insn "*negsi2_1_zext"
>    [(set (match_operand:DI 0 "register_operand" "=r")
> -	(lshiftrt:DI
> -	  (neg:DI (ashift:DI (match_operand:DI 1 "register_operand" "0")
> -			     (const_int 32)))
> -	(const_int 32)))
> +	(zero_extend:DI
> +	  (neg:SI (match_operand:SI 1 "register_operand" "0"))))
>     (clobber (reg:CC FLAGS_REG))]

Thanks for adding a testcase!


Segher
diff mbox series

Patch

Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md	(revision 274169)
+++ config/i386/i386.md	(working copy)
@@ -9337,13 +9337,10 @@ 
   [(set_attr "type" "negnot")
    (set_attr "mode" "<MODE>")])
 
-;; Combine is quite creative about this pattern.
 (define_insn "*negsi2_1_zext"
   [(set (match_operand:DI 0 "register_operand" "=r")
-	(lshiftrt:DI
-	  (neg:DI (ashift:DI (match_operand:DI 1 "register_operand" "0")
-			     (const_int 32)))
-	(const_int 32)))
+	(zero_extend:DI
+	  (neg:SI (match_operand:SI 1 "register_operand" "0"))))
    (clobber (reg:CC FLAGS_REG))]
   "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
   "neg{l}\t%k0"
@@ -9369,16 +9366,11 @@ 
 (define_insn "*negsi2_cmpz_zext"
   [(set (reg:CCZ FLAGS_REG)
 	(compare:CCZ
-	  (lshiftrt:DI
-	    (neg:DI (ashift:DI
-		      (match_operand:DI 1 "register_operand" "0")
-		      (const_int 32)))
-	    (const_int 32))
+	  (neg:SI (match_operand:SI 1 "register_operand" "0"))
 	  (const_int 0)))
    (set (match_operand:DI 0 "register_operand" "=r")
-	(lshiftrt:DI (neg:DI (ashift:DI (match_dup 1)
-					(const_int 32)))
-		     (const_int 32)))]
+	(zero_extend:DI
+	  (neg:SI (match_dup 1))))]
   "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
   "neg{l}\t%k0"
   [(set_attr "type" "negnot")
@@ -9698,7 +9690,6 @@ 
   [(set_attr "type" "negnot")
    (set_attr "mode" "<MODE>")])
 
-;; ??? Currently never generated - xor is used instead.
 (define_insn "*one_cmplsi2_1_zext"
   [(set (match_operand:DI 0 "register_operand" "=r")
 	(zero_extend:DI
@@ -9749,7 +9740,6 @@ 
 	      (set (match_dup 1)
 		   (xor:SWI (match_dup 3) (const_int -1)))])])
 
-;; ??? Currently never generated - xor is used instead.
 (define_insn "*one_cmplsi2_2_zext"
   [(set (reg FLAGS_REG)
 	(compare (not:SI (match_operand:SI 1 "register_operand" "0"))
Index: testsuite/gcc.target/i386/pr91385.c
===================================================================
--- testsuite/gcc.target/i386/pr91385.c	(nonexistent)
+++ testsuite/gcc.target/i386/pr91385.c	(working copy)
@@ -0,0 +1,9 @@ 
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-O2 -dp" } */
+/* { dg-final { scan-assembler-not "zero_extendsidi" } } */
+
+unsigned long long
+foo (unsigned int a)
+{
+  return -a;
+}