diff mbox series

[committed] i386: Improve cmpstrnqi_1 insn pattern [PR112494]

Message ID CAFULd4aSFZErfqJo8Op4Y6i08D_XcQ=5F+MWJ1fSHAdWMYaWYg@mail.gmail.com
State New
Headers show
Series [committed] i386: Improve cmpstrnqi_1 insn pattern [PR112494] | expand

Commit Message

Uros Bizjak Nov. 28, 2023, 3:59 p.m. UTC
REPZ CMPSB instruction does not update FLAGS register when %ecx register
equals zero.  Improve cmpstrnqi_1 insn pattern to set FLAGS_REG to its
previous value instead of (const_int 0) when operand 2 equals zero.

    PR target/112494

gcc/ChangeLog:

    * config/i386/i386.md (cmpstrnqi_1): Set FLAGS_REG to its previous
    value when operand 2 equals zero.
    (*cmpstrnqi_1): Ditto.
    (*cmpstrnqi_1 peephole2): Ditto.

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

Uros.
diff mbox series

Patch

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index cb32de7fab8..7641b479670 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -23333,9 +23333,8 @@  (define_expand "cmpstrnqi_1"
 				     (const_int 0))
 		  (compare:CC (match_operand 4 "memory_operand")
 			      (match_operand 5 "memory_operand"))
-		  (const_int 0)))
+		  (reg:CC FLAGS_REG)))
 	      (use (match_operand:SI 3 "immediate_operand"))
-	      (use (reg:CC FLAGS_REG))
 	      (clobber (match_operand 0 "register_operand"))
 	      (clobber (match_operand 1 "register_operand"))
 	      (clobber (match_dup 2))])]
@@ -23351,9 +23350,8 @@  (define_insn "*cmpstrnqi_1"
 			     (const_int 0))
 	  (compare:CC (mem:BLK (match_operand:P 4 "register_operand" "0"))
 		      (mem:BLK (match_operand:P 5 "register_operand" "1")))
-	  (const_int 0)))
+	  (reg:CC FLAGS_REG)))
    (use (match_operand:SI 3 "immediate_operand" "i"))
-   (use (reg:CC FLAGS_REG))
    (clobber (match_operand:P 0 "register_operand" "=S"))
    (clobber (match_operand:P 1 "register_operand" "=D"))
    (clobber (match_operand:P 2 "register_operand" "=c"))]
@@ -23464,9 +23462,8 @@  (define_peephole2
 			       (const_int 0))
 	    (compare:CC (mem:BLK (match_operand 4 "register_operand"))
 		        (mem:BLK (match_operand 5 "register_operand")))
-	    (const_int 0)))
+	    (reg:CC FLAGS_REG)))
      (use (match_operand:SI 3 "immediate_operand"))
-     (use (reg:CC FLAGS_REG))
      (clobber (match_operand 0 "register_operand"))
      (clobber (match_operand 1 "register_operand"))
      (clobber (match_operand 2 "register_operand"))])
@@ -23484,9 +23481,8 @@  (define_peephole2
 			       (const_int 0))
 	    (compare:CC (mem:BLK (match_dup 4))
 			(mem:BLK (match_dup 5)))
-	    (const_int 0)))
+	    (reg:CC FLAGS_REG)))
      (use (match_dup 3))
-     (use (reg:CC FLAGS_REG))
      (clobber (match_dup 0))
      (clobber (match_dup 1))
      (clobber (match_dup 2))])])