optabs.c: Comment that gen_add2_insn and others may actually return emitted insns...
authorAlexandre Oliva <aoliva@redhat.com>
Wed, 9 Apr 2003 17:50:08 +0000 (17:50 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Wed, 9 Apr 2003 17:50:08 +0000 (17:50 +0000)
* optabs.c: Comment that gen_add2_insn and others may actually
return emitted insns, if the gen functions turn out to return
emitted insns.
* reload1.c (reload_cse_move2add): Cope with emitted insns from
gen_add2_insn.

From-SVN: r65400

gcc/ChangeLog
gcc/optabs.c
gcc/reload1.c

index 2b13098ff899ea4635492534289476b90d32acd7..62a4853972c09ba04fe9ea99fe6cab218768ac10 100644 (file)
@@ -1,3 +1,11 @@
+2003-04-09  Alexandre Oliva  <aoliva@redhat.com>
+
+       * optabs.c: Comment that gen_add2_insn and others may actually
+       return emitted insns, if the gen functions turn out to return
+       emitted insns.
+       * reload1.c (reload_cse_move2add): Cope with emitted insns from
+       gen_add2_insn.
+
 2003-04-09  Richard Henderson  <rth@redhat.com>
 
        * config/ia64/ia64.c (move_operand): Allow symbolic_operand,
index bd5c385cec55a8ffd506a7d5cad569fd1062ed64..14d93c65fe8392dce373f3b3fdb5c6a92487c75f 100644 (file)
@@ -4512,8 +4512,9 @@ emit_conditional_add (target, code, op0, op1, cmode, op2, op3, mode,
   return target;
 }
 \f
-/* These functions generate an insn body and return it
-   rather than emitting the insn.
+/* These functions attempt to generate an insn body, rather than
+   emitting the insn, but if the gen function already emits them, we
+   make no attempt to turn them back into naked patterns.
 
    They do not protect from queued increments,
    because they may be used 1) in protect_from_queue itself
index c70694bedfdac2b0df6cf2d91a559caba8598e68..a6e41ddeae26fe00a5eb1f23849042523cdb961b 100644 (file)
@@ -9162,8 +9162,16 @@ reload_cse_move2add (first)
                    validate_change (insn, &SET_SRC (pat), reg, 0);
                  else if (rtx_cost (new_src, PLUS) < rtx_cost (src, SET)
                           && have_add2_insn (reg, new_src))
-                   validate_change (insn, &PATTERN (insn),
-                                    gen_add2_insn (reg, new_src), 0);
+                   {
+                     rtx newpat = gen_add2_insn (reg, new_src);
+                     if (INSN_P (newpat) && NEXT_INSN (newpat) == NULL_RTX)
+                       newpat = PATTERN (newpat);
+                     /* If it was the first insn of a sequence or
+                        some other emitted insn, validate_change will
+                        reject it.  */
+                     validate_change (insn, &PATTERN (insn),
+                                      newpat, 0);
+                   }
                  else
                    {
                      enum machine_mode narrow_mode;
@@ -9243,9 +9251,15 @@ reload_cse_move2add (first)
                      else if ((rtx_cost (new_src, PLUS)
                                < COSTS_N_INSNS (1) + rtx_cost (src3, SET))
                               && have_add2_insn (reg, new_src))
-                       success
-                         = validate_change (next, &PATTERN (next),
-                                            gen_add2_insn (reg, new_src), 0);
+                       {
+                         rtx newpat = gen_add2_insn (reg, new_src);
+                         if (INSN_P (newpat)
+                             && NEXT_INSN (newpat) == NULL_RTX)
+                           newpat = PATTERN (newpat);
+                         success
+                           = validate_change (next, &PATTERN (next),
+                                              newpat, 0);
+                       }
                      if (success)
                        delete_insn (insn);
                      insn = next;