On 6/14/19 6:51 AM, Jiufu Guo wrote:
> Jeff Law <l...@redhat.com> writes:
> 
>> On 6/3/19 11:28 PM, Jiufu Guo wrote:
>>>
>>> Hi,
>>>
>>> This patch implements a new opportunity of jump threading for PR77820.
>>> In this optimization, conditional jumps are merged with unconditional
>>> jump. And then moving CMP result to GPR is eliminated.
>>>
>>> This version is based on the proposal of Richard, Jeff and Andrew on
>>> previous versions, and refined to incorporate comments, such as accept
>>> the path with single_succ_p (e->src).
>>> Thanks for the reviews!
>>>
>>> Bootstrapped and tested on powerpc64le, powerpc64 and sh (with help
>>> from Jeff) with no regressions (two cases are improved and updated
>>> to keep original test coverage) and new testcases are added.
>>> Is this ok for trunk?
>>>
>>> Example of this opportunity looks like below:
>>>
>>>   <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>;
>>>
>>> Could be transformed 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>;
>>>
>>>
>>> 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) p0 if there is.
>>>
>>> Thanks!
>>> Jiufu Guo
>>>
>>> [gcc]
>>> 2019-06-04  Jiufu Guo  <guoji...@linux.ibm.com>
>>>         Lijia He  <heli...@linux.ibm.com>
>>>
>>>     PR tree-optimization/77820
>>>     * tree-ssa-threadedge.c
>>>     (edge_forwards_cmp_to_conditional_jump_through_empty_bb_p): New
>>>     function.
>>>     (thread_across_edge): Add call to
>>>     edge_forwards_cmp_to_conditional_jump_through_empty_bb_p.
>>>
>>> [gcc/testsuite]
>>> 2019-06-04  Jiufu Guo  <guoji...@linux.ibm.com>
>>>         Lijia He  <heli...@linux.ibm.com>
>>>
>>>     PR tree-optimization/77820
>>>     * gcc.dg/tree-ssa/phi_on_compare-1.c: New testcase.
>>>     * gcc.dg/tree-ssa/phi_on_compare-2.c: New testcase.
>>>     * gcc.dg/tree-ssa/phi_on_compare-3.c: New testcase.
>>>     * gcc.dg/tree-ssa/phi_on_compare-4.c: New testcase.
>>>     * gcc.dg/tree-ssa/split-path-6.c: Update testcase.
>>>     * gcc.target/sh/pr51244-20.c: Update testcase.
>> Yes, this is OK for the trunk.  I'll commit it momentarily.
> Thanks Jeff! I got svn access,  I could commit next time. 
Yea, Segher pointed that out to me in IRC.  Looking forward to your next
patchkit :-)

jeff

Reply via email to