In a few cases, obviously omitable add instructions can be emitted via
invoking gen_addsi3.

gcc/ChangeLog:

        * config/xtensa/xtensa.md (addsi3_internal): Rename from "addsi3".
        (addsi3): New define_expand in order to reject integer additions of
        constant zero.
---
 gcc/config/xtensa/xtensa.md | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
index 9eeb73915..c132c1626 100644
--- a/gcc/config/xtensa/xtensa.md
+++ b/gcc/config/xtensa/xtensa.md
@@ -156,7 +156,19 @@
 
 ;; Addition.
 
-(define_insn "addsi3"
+(define_expand "addsi3"
+  [(set (match_operand:SI 0 "register_operand")
+       (plus:SI (match_operand:SI 1 "register_operand")
+                (match_operand:SI 2 "add_operand")))]
+  ""
+{
+  if (! CONST_INT_P (operands[2]) || INTVAL (operands[2]) != 0)
+    emit_insn (gen_addsi3_internal (operands[0],
+                                   operands[1], operands[2]));
+  DONE;
+})
+
+(define_insn "addsi3_internal"
   [(set (match_operand:SI 0 "register_operand" "=D,D,a,a,a")
        (plus:SI (match_operand:SI 1 "register_operand" "%d,d,r,r,r")
                 (match_operand:SI 2 "add_operand" "d,O,r,J,N")))]
-- 
2.20.1

Reply via email to