Starting from revision 160625 (http://gcc.gnu.org/ml/gcc-patches/2010-06/msg01155.html) if-conversion generates redundant statements for for (i = 0; i < N; i++) if (arr[i] < limit) { pos = i + 1; limit = arr[i]; } # pos_22 = PHI <pos_1(4), 1(2)> # i_23 = PHI <prephitmp.8_2(4), 0(2)> # limit_24 = PHI <limit_4(4), 1.28e+2(2)> # ivtmp.9_18 = PHI <ivtmp.9_17(4), 64(2)> limit_9 = arr[i_23]; pos_10 = i_23 + 1; D.4534_12 = limit_9 < limit_24; <----- pretmp.7_3 = i_23 + 1; D.4535_20 = limit_9 >= limit_24; <----- pos_1 = [cond_expr] limit_9 >= limit_24 ? pos_22 : pos_10; limit_4 = [cond_expr] limit_9 >= limit_24 ? limit_24 : limit_9; prephitmp.8_2 = [cond_expr] limit_9 >= limit_24 ? pretmp.7_3 : pos_10; ivtmp.9_17 = ivtmp.9_18 - 1; D.4536_19 = D.4534_12 || D.4535_20; <----- if (ivtmp.9_17 != 0) goto <bb 4>; else goto <bb 5>; The statements are removed by later dce pass, but they interfere with my attempts to vectorize this loop.
Created attachment 21036 [details] Full testcase
Mine. Patch 0005 of http://gcc.gnu.org/ml/gcc-patches/2010-06/msg02250.html fixes exactly this problem. I have not yet worked on correcting the patch as Richi asked.
Subject: Bug 44710 Author: spop Date: Thu Jul 8 16:38:00 2010 New Revision: 161964 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161964 Log: Call maybe_fold_or_comparisons to fold OR-ed predicates. 2010-07-08 Sebastian Pop <sebastian.pop@amd.com> PR tree-optimization/44710 * tree-if-conv.c (parse_predicate): New. (add_to_predicate_list): Call it, call maybe_fold_or_comparisons. Make sure that the predicates are either SSA_NAMEs or gimple_condexpr. * gcc.dg/tree-ssa/ifc-6.c: New. * gcc.dg/tree-ssa/ifc-pr44710.c: New. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/ifc-6.c trunk/gcc/testsuite/gcc.dg/tree-ssa/ifc-pr44710.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-if-conv.c
Fixed.