On Tue, Mar 22, 2016 at 10:41 AM, Richard Biener <richard.guent...@gmail.com> wrote: > On Mon, Mar 21, 2016 at 4:22 PM, Bin Cheng <bin.ch...@arm.com> wrote: >> Hi, >> The second issue revealed by PR69489 is tree ifcvt could not convert PHI >> nodes with more than 2 arguments. Among these nodes, there is a special >> kind of PHI which can be handled. Precisely, if the PHI node satisfies >> below two conditions: >> 1) Number of PHI arguments with different values equals to 2 and one >> argument has the only occurrence. >> 2) The edge corresponding to the unique argument isn't critical edge. >> >> Such PHI can be degenerated and handled just like PHI node with only two >> arguments. For example: >> res = PHI <A_1(e1), A_1(e2), A_2(e3), A_1(e4)>; >> can be transformed into: >> res = (predicate of e3) ? A_2 : A_1; >> >> This patch fixes the issue. I know we may be able to further relax the >> check and allow handling of general multiple args PHI node, this can be a >> starter since the change is kind of trivial. >> Bootstrap & test on x86_64 & AArch64. Though the first part patch at >> https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00888.html needs to be >> revised, this one is quite independent apart from the test case itself. So >> any opinions? > > Looks good to me. Btw, see also PR56541 where jump threading can Patch re-tested and applied on trunk with below minor change: + unsigned int i, i1, i2, n1 = 0, n2 = 0; Changed to: + unsigned int i, i1 = 0, i2 = 0, n1 = 0, n2 = 0; Because GCC falsely reports uninitialized use of `i2' at O2 optimization level, resulting in bootstrap failure.
> introduce the case but with more than two distinct PHI args. > IMHO we "simply" want to force *amy_mask_load_store to true if > if_convertible_phi_p runs into this case (so we perform > versioning to only expose the if-converted code to the vectorizer > which has a cost model to tell whether the result is profitable). > There is still the critical edge splitting only performed for > aggressive-if-conv but I think that's easily sth we can do for all > loop > bodies. Yeah, I have following patch to handle such cases. Thanks, bin > > Richard. > >> Thanks, >> bin >> >> 2016-03-21 Bin Cheng <bin.ch...@arm.com> >> >> PR tree-optimization/69489 >> * tree-if-conv.c (phi_convertible_by_degenerating_args): New. >> (if_convertible_phi_p): Call phi_convertible_by_degenerating_args. >> Revise dump message. >> (if_convertible_bb_p): Remove check on edge count of basic block's >> predecessors. >> >> gcc/testsuite/ChangeLog >> 2016-03-21 Bin Cheng <bin.ch...@arm.com> >> >> PR tree-optimization/69489 >> * gcc.dg/tree-ssa/ifc-pr69489-2.c: New test.