This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: problem with iv-opts and valid gimple
Hello,
>
> On Dec 10, 2004, at 3:48 PM, Andrew Pinski wrote:
>
> >Even though I cannot find a testcase on the mainline, I could reproduce
> >the problem with my tree combiner.
> >
> >find_interesting_uses_cond does not handle TRUTH_NOT_EXPR.
> >
> >Could you look into how to fix this problem?
> >This might be able to reproducible on the mainline but I cannot
> >find a testcase right now.
making it kinda hard to test :-). Given that find_interesting_uses_cond
would ICE with TRUTH_NOT_EXPR, it probably cannot be reproduced easily.
Try the patch below.
Zdenek
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.35
diff -c -3 -p -r2.35 tree-ssa-loop-ivopts.c
*** tree-ssa-loop-ivopts.c 7 Dec 2004 21:23:04 -0000 2.35
--- tree-ssa-loop-ivopts.c 10 Dec 2004 21:09:41 -0000
*************** find_interesting_uses_cond (struct ivopt
*** 1206,1211 ****
--- 1206,1216 ----
op0_p = cond_p;
op1_p = &zero;
}
+ else if (TREE_CODE (*cond_p) == TRUTH_NOT_EXPR)
+ {
+ op0_p = &TREE_OPERAND (*cond_p, 0);
+ op1_p = &zero;
+ }
else
{
op0_p = &TREE_OPERAND (*cond_p, 0);
*************** determine_use_iv_cost_condition (struct
*** 3255,3260 ****
--- 3313,3320 ----
rid of it. */
if (TREE_CODE (*use->op_p) == SSA_NAME)
record_invariant (data, *use->op_p, true);
+ else if (TREE_CODE (*use->op_p) == TRUTH_NOT_EXPR)
+ record_invariant (data, TREE_OPERAND (*use->op_p, 0), true);
else
{
record_invariant (data, TREE_OPERAND (*use->op_p, 0), true);
*************** rewrite_use_compare (struct ivopts_data
*** 4544,4553 ****
comp = unshare_expr (get_computation (data->current_loop, use, cand));
cond = *use->op_p;
! op_p = &TREE_OPERAND (cond, 0);
! if (TREE_CODE (*op_p) != SSA_NAME
! || zero_p (get_iv (data, *op_p)->step))
! op_p = &TREE_OPERAND (cond, 1);
op = force_gimple_operand (comp, &stmts, true, SSA_NAME_VAR (*op_p));
if (stmts)
--- 4625,4639 ----
comp = unshare_expr (get_computation (data->current_loop, use, cand));
cond = *use->op_p;
! if (TREE_CODE (cond) == SSA_NAME)
! op_p = use->op_p;
! else
! {
! op_p = &TREE_OPERAND (cond, 0);
! if (TREE_CODE (*op_p) != SSA_NAME
! || zero_p (get_iv (data, *op_p)->step))
! op_p = &TREE_OPERAND (cond, 1);
! }
op = force_gimple_operand (comp, &stmts, true, SSA_NAME_VAR (*op_p));
if (stmts)