diff options
author | Ulrich Weigand <uweigand@de.ibm.com> | 2002-03-13 13:00:25 +0000 |
---|---|---|
committer | Ulrich Weigand <uweigand@gcc.gnu.org> | 2002-03-13 13:00:25 +0000 |
commit | c0a3eeacdacc658c531709c785772d329d3c4ebd (patch) | |
tree | 581a10abb92918df29f061b0aa17adae068cb158 /gcc/expr.c | |
parent | a1652cee9a2e7c8d25c0179aed8addf8f9c4f0aa (diff) | |
download | gcc-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.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -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, |