This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[vtab and trunk?] ifcvt: try 'then' only if 'else' is unsuitable
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 01 Oct 2007 17:15:01 -0300
- Subject: [vtab and trunk?] ifcvt: try 'then' only if 'else' is unsuitable
If we try to handle an if/then/else construct whose else is unsuitable
for ifcvt (in my case, because it contained debug notes, before I
arranged for them to be ignored), but whose then is, retrying the
conversion discarding the else may be useful.
The patch below actually detects early the case of a bad else so as to
avoid the first miss.
Bootstrapped on x86_64-linux-gnu. Is this appropriate for trunk at
this point, or should I keep it in vtab only, if at all?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* ifcvt.c (noce_process_if_block): Try to handle only the then
block if the else block exists but isn't suitable.
Index: gcc/ifcvt.c
===================================================================
--- gcc/ifcvt.c.orig 2007-09-08 20:07:17.000000000 -0300
+++ gcc/ifcvt.c 2007-09-08 20:07:22.000000000 -0300
@@ -2204,6 +2204,7 @@ noce_process_if_block (struct noce_if_in
|| !NONJUMP_INSN_P (insn_b)
|| (set_b = single_set (insn_b)) == NULL_RTX
|| ! rtx_equal_p (x, SET_DEST (set_b))
+ || ! noce_operand_ok (SET_SRC (set_b))
|| reg_overlap_mentioned_p (x, SET_SRC (set_b))
|| modified_between_p (SET_SRC (set_b),
PREV_INSN (if_info->cond_earliest), jump)
@@ -2249,6 +2250,7 @@ noce_process_if_block (struct noce_if_in
if (! noce_operand_ok (a) || ! noce_operand_ok (b))
return FALSE;
+ retry:
/* Set up the info block for our subroutines. */
if_info->insn_a = insn_a;
if_info->insn_b = insn_b;
@@ -2332,6 +2334,13 @@ noce_process_if_block (struct noce_if_in
goto success;
}
+ if (!else_bb && set_b)
+ {
+ insn_b = set_b = NULL_RTX;
+ b = orig_x;
+ goto retry;
+ }
+
return FALSE;
success:
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member http://www.fsfla.org/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}