expr.c (expand_expr, [...]): Do not call copy_to_reg with VOIDmode operand.
authorUlrich Weigand <uweigand@de.ibm.com>
Wed, 13 Mar 2002 13:00:25 +0000 (13:00 +0000)
committerUlrich Weigand <uweigand@gcc.gnu.org>
Wed, 13 Mar 2002 13:00:25 +0000 (13:00 +0000)
* expr.c (expand_expr, case NE_EXPR): Do not call copy_to_reg with
VOIDmode operand.  Add compile-time optimization for constant results.

From-SVN: r50734

gcc/ChangeLog
gcc/expr.c

index 3c1aaaf1224c8744e225ab38415e32f73756e319..cf1127efd733854d414f7546afea92342fae0c3e 100644 (file)
@@ -1,3 +1,8 @@
+2002-03-13  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       * expr.c (expand_expr, case NE_EXPR): Do not call copy_to_reg with
+       VOIDmode operand.  Add compile-time optimization for constant results.
+
 2002-03-12  Jason Merrill  <jason@redhat.com>
 
        * c-typeck.c (convert_for_assignment): Don't allow conversions
index ac756432f20be533d25cbf55f0973ca3fcdfc8a4..5aed1dc0828fbf6c2e73bae74a0abe335bcd7e29 100644 (file)
@@ -7944,8 +7944,25 @@ expand_expr (exp, target, tmode, modifier)
          temp = expand_expr (TREE_OPERAND (exp, 0), original_target,
                              VOIDmode, 0);
 
+         /* If temp is constant, we can just compute the result.  */
+         if (GET_CODE (temp) == CONST_INT)
+           {
+             if (INTVAL (temp) != 0)
+               emit_move_insn (target, const1_rtx);
+             else
+               emit_move_insn (target, const0_rtx);
+
+             return target;
+           }
+
          if (temp != original_target)
-           temp = copy_to_reg (temp);
+           {
+             enum machine_mode mode1 = GET_MODE (temp);
+             if (mode1 == VOIDmode)
+               mode1 = tmode != VOIDmode ? tmode : mode;
+             
+             temp = copy_to_mode_reg (mode1, temp);
+           }
 
          op1 = gen_label_rtx ();
          emit_cmp_and_jump_insns (temp, const0_rtx, EQ, NULL_RTX,