This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
If-conversion misses many cases
- From: "Jan Hoogerbrugge" <hoogerbrugge at hotmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 23 Feb 2004 10:30:22 +0100
- Subject: If-conversion misses many cases
- Bcc:
Hi,
My target architecture supports predication so I expressed that in
my machine description. This is what I added:
(define_attr "predicable" "no,yes" (const_string "yes"))
(define_cond_exec
[(match_operator 0 "predicate_operator"
[(match_operand:BI 1 "register_operand" "r")
(const_int 0)])]
""
"if %J0"
)
int predicate_operator(rtx op, enum machine_mode mode)
{
enum rtx_code code = GET_CODE(op);
return (GET_MODE(op) == mode || mode == VOIDmode) &&
(code == EQ || code == NE);
}
#define MAX_CONDITIONAL_EXECUTE 12
I see some if=conversion happening but I don't see it happening in
many simple cases where I would expect it. In the following set of
test cases it only happens in foo4.
int s;
int t;
void foo(int a) { if(a > 0) s = 0; }
void foo2(int a) { if(a == 0) s = 0; }
void foo3(int a) { if(a == 3) s = 0; else t = 0; }
void foo4(int a, int *p) { if(a >= 4) *p = 1; }
void foo5(int a, int *p) { if(a == 3) *p = 0; if(a == 0) s = 0; }
void foo6(int a, int *p) { if(a == 3) s = 0; else *p = 2; }
void foo7(int a, int *p) { if(a & 1) s = 0; else *p = 2; }
void foo8(int a, int *p) { if((a & 1) == 0) s = 0; else *p = 2; }
The IA64 port applies if-conversion in all these cases. So I am
wondering why I am missing so many opportunities for if-conversion.
When I compare execution traces for my architecture and IA64 for
this case
int s;
void foo(int a) { int *p = &s; if(a > 0) *p = 0; }
I see differences in the modified_in_p (test, insn) test in
cond_exec_process_insns. For IA64, this tests returns false, for my target
(TriMedia) it returns true, which causes that must_be_last is set and
that causes that cond_exec_process_insns returns false. I don't understand
what is going on here so I would appreciate some help to find out why
if-conversion is so infrequently happening. Anybody who can help me?
Thanks,
Jan
_________________________________________________________________
Talk with your online friends with MSN Messenger http://messenger.msn.nl/