aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2002-03-13 13:00:25 +0000
committerUlrich Weigand <uweigand@gcc.gnu.org>2002-03-13 13:00:25 +0000
commitc0a3eeacdacc658c531709c785772d329d3c4ebd (patch)
tree581a10abb92918df29f061b0aa17adae068cb158 /gcc/expr.c
parenta1652cee9a2e7c8d25c0179aed8addf8f9c4f0aa (diff)
downloadgcc-c0a3eeacdacc658c531709c785772d329d3c4ebd.zip
gcc-c0a3eeacdacc658c531709c785772d329d3c4ebd.tar.gz
gcc-c0a3eeacdacc658c531709c785772d329d3c4ebd.tar.bz2
expr.c (expand_expr, [...]): Do not call copy_to_reg with VOIDmode operand.
* 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
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index ac75643..5aed1dc 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -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,