This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH PR69489/02]Handle PHI which can be degenerated to two arguments node in tree ifcvt.


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?

Thanks,
bin

2016-03-21  Bin Cheng  <bin.cheng@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.cheng@arm.com>

	PR tree-optimization/69489
	* gcc.dg/tree-ssa/ifc-pr69489-2.c: New test.

Attachment: pr69489-part2-20160316.txt
Description: pr69489-part2-20160316.txt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]