[PATCH] Fix copy_to_reg ICE in expand_expr

Ulrich Weigand Ulrich.Weigand@de.ibm.com
Wed Mar 13 05:05:00 GMT 2002


Richard Henderson wrote:

>On Fri, Mar 08, 2002 at 05:02:14PM +0100, Ulrich Weigand wrote:
>> Is it OK to check in the patch from my last mail, see below?
>> Or should I check in only the first part (which you'd already okayed
>> if I understood correctly)?
>
>Both parts are ok.

OK, I've checked in the patch below on trunk and branch.
Bootstrapped/regtested on s390-ibm-linux on s390x-ibm-linux,
both on the trunk and on the branch.

Thanks,
Ulrich

ChangeLog:

      * expr.c (expand_expr, case NE_EXPR): Do not call copy_to_reg with
      VOIDmode operand.  Add compile-time optimization for constant results.


Index: gcc/expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.425
diff -c -p -r1.425 expr.c
*** expr.c  2002/03/01 01:19:48     1.425
--- expr.c  2002/03/08 15:40:37
*************** expand_expr (exp, target, tmode, modifie
*** 7942,7949 ****
        temp = expand_expr (TREE_OPERAND (exp, 0), original_target,
                        VOIDmode, 0);

        if (temp != original_target)
!         temp = copy_to_reg (temp);

        op1 = gen_label_rtx ();
        emit_cmp_and_jump_insns (temp, const0_rtx, EQ, NULL_RTX,
--- 7942,7966 ----
        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)
!         {
!           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,






More information about the Gcc-patches mailing list