Jeff Law <l...@redhat.com> writes: > On 5/6/19 8:24 AM, Jiufu Guo wrote: >> Hi, >> >> This patch implements the optimization in PR77820. The optimization >> eliminates phi and phi's basic block, if the phi is used only by >> condition branch, and the phi's incoming value in the result of a >> CMP result. >> >> This optimization eliminates: >> 1. saving CMP result: p0 = a CMP b. >> 2. additional CMP on branch: if (phi != 0). >> 3. converting CMP result if there is phi = (INT_CONV) p0 if there is. >> >> <P0> >> p0 = a CMP b >> goto <X>; >> >> <P1> >> p1 = c CMP d >> goto <X>; >> >> <X> >> # phi = PHI <p0 (P0), p1 (P1)> >> if (phi != 0) goto <Y>; else goto <Z>; >> >> Transform to: >> >> <P0> >> p0 = a CMP b >> if (p0 != 0) goto <Y>; else goto <Z>; >> >> <P1> >> p1 = c CMP d >> if (p1 != 0) goto <Y>; else goto <Z>; >> >> Bootstrapped and tested on powerpc64le with no regressions, and testcases >> were >> saved. Is this ok for trunk? > So there's been talk of somehow integrating with jump threading. The > big problem with that idea is jump threading is only concerned with > rearranging the CFG when doing so allows it to determine the result of a > conditional branch. > > This is actually a generalized form of path splitting that we currently > do for loop latches. You may find you can twiddle that code to do what > you want. > > One of the things that falls out of that realization is that you have to > be very careful that this doesn't muck up if-conversion. > > Jeff
Thanks for all your suggeustions: Richard, Segher, Andrew and Jeff! Will send new patch after investigating and code refining. Jiufu Guo.