From: Ulrich Weigand Date: Tue, 16 Aug 2011 18:39:55 +0000 (+0000) Subject: spu.c (spu_emit_branch_or_set): Avoid reverse tests when generating an integer result... X-Git-Tag: releases/gcc-4.7.0~4430 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0b01f61969d2595b11f988ef2a97d3b2b986d175;p=thirdparty%2Fgcc.git spu.c (spu_emit_branch_or_set): Avoid reverse tests when generating an integer result where possible. * config/spu/spu.c (spu_emit_branch_or_set): Avoid reverse tests when generating an integer result where possible. Short-cut comparison against 0 also for QImode. From-SVN: r177795 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 67ae4ed82637..1a43c1211f34 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-08-16 Ulrich Weigand + + * config/spu/spu.c (spu_emit_branch_or_set): Avoid reverse tests + when generating an integer result where possible. Short-cut + comparison against 0 also for QImode. + 2011-08-16 Ulrich Weigand * config/spu/spu.h (LEGITIMIZE_RELOAD_ADDRESS): New macro. diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c index 7868c7f98107..b8e3fb35da3a 100644 --- a/gcc/config/spu/spu.c +++ b/gcc/config/spu/spu.c @@ -982,6 +982,27 @@ spu_emit_branch_or_set (int is_set, rtx cmp, rtx operands[]) } } + /* However, if we generate an integer result, performing a reverse test + would require an extra negation, so avoid that where possible. */ + if (GET_CODE (op1) == CONST_INT && is_set == 1) + { + HOST_WIDE_INT val = INTVAL (op1) + 1; + if (trunc_int_for_mode (val, GET_MODE (op0)) == val) + switch (code) + { + case LE: + op1 = GEN_INT (val); + code = LT; + break; + case LEU: + op1 = GEN_INT (val); + code = LTU; + break; + default: + break; + } + } + comp_mode = SImode; op_mode = GET_MODE (op0); @@ -1113,7 +1134,8 @@ spu_emit_branch_or_set (int is_set, rtx cmp, rtx operands[]) if (is_set == 0 && op1 == const0_rtx && (GET_MODE (op0) == SImode - || GET_MODE (op0) == HImode) && scode == SPU_EQ) + || GET_MODE (op0) == HImode + || GET_MODE (op0) == QImode) && scode == SPU_EQ) { /* Don't need to set a register with the result when we are comparing against zero and branching. */