[gcc(refs/users/aoliva/heads/testme)] x86: more lea peephole improvements

Alexandre Oliva aoliva@gcc.gnu.org
Sat Dec 13 08:46:46 GMT 2025


https://gcc.gnu.org/g:973f6500c7a31b0dd0a470d1401a73cc475fc34e

commit 973f6500c7a31b0dd0a470d1401a73cc475fc34e
Author: Alexandre Oliva <oliva@gnu.org>
Date:   Sat Dec 13 04:12:10 2025 -0300

    x86: more lea peephole improvements

Diff:
---
 gcc/config/i386/i386.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 7eafdf9ec1b6..139cddaa4116 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -6494,6 +6494,58 @@
   [(set (match_dup 3) (plus:SWI48 (plus:SWI48 (match_dup 0)
 					      (match_dup 1))
 				  (match_dup 2)))])
+
+(define_peephole2
+  [(set (match_operand:SWI48 0 "register_operand")
+	(plus:SWI48 (match_dup 0)
+		    (match_operand 1 "register_operand")))
+   (parallel [(set (match_dup 0)
+		   (plus:SWI48 (match_dup 0)
+			       (match_operand 2 "x86_64_immediate_operand")))
+	      (clobber (reg:CC FLAGS_REG))])]
+  "!TARGET_AVOID_LEA_FOR_ADDR || optimize_function_for_size_p (cfun)"
+  [(set (match_dup 0) (plus:SWI48 (plus:SWI48 (match_dup 0)
+					      (match_dup 1))
+				  (match_dup 2)))])
+
+(define_peephole2
+  [(set (match_operand:SWI48 0 "register_operand")
+	(plus:SWI48 (match_dup 0)
+		    (match_operand 1 "register_operand")))
+   (set (match_dup 0)
+	(plus:SWI48 (match_dup 0)
+		    (match_operand 2 "x86_64_immediate_operand")))]
+  "!TARGET_AVOID_LEA_FOR_ADDR || optimize_function_for_size_p (cfun)"
+  [(set (match_dup 0) (plus:SWI48 (plus:SWI48 (match_dup 0)
+					      (match_dup 1))
+				  (match_dup 2)))])
+
+(define_peephole2
+  [(set (match_operand:SWI48 0 "register_operand")
+	(plus:SWI48 (match_dup 0)
+		    (match_operand 1 "register_operand")))
+   (parallel [(set (match_operand:SWI48 3 "register_operand")
+		   (plus:SWI48 (match_dup 0)
+			       (match_operand 2 "x86_64_immediate_operand")))
+	      (clobber (reg:CC FLAGS_REG))])]
+  "(!TARGET_AVOID_LEA_FOR_ADDR || optimize_function_for_size_p (cfun))
+   && peep2_reg_dead_p (2, operands[0])"
+  [(set (match_dup 3) (plus:SWI48 (plus:SWI48 (match_dup 0)
+					      (match_dup 1))
+				  (match_dup 2)))])
+
+(define_peephole2
+  [(set (match_operand:SWI48 0 "register_operand")
+	(plus:SWI48 (match_dup 0)
+		    (match_operand 1 "register_operand")))
+   (set (match_operand:SWI48 3 "register_operand")
+	(plus:SWI48 (match_dup 0)
+		    (match_operand 2 "x86_64_immediate_operand")))]
+  "(!TARGET_AVOID_LEA_FOR_ADDR || optimize_function_for_size_p (cfun))
+   && peep2_reg_dead_p (2, operands[0])"
+  [(set (match_dup 3) (plus:SWI48 (plus:SWI48 (match_dup 0)
+					      (match_dup 1))
+				  (match_dup 2)))])
 
 ;; Add instructions


More information about the Gcc-cvs mailing list