This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Short Circuit compiler transformations!!
- From: Ajit Kumar Agarwal <ajit dot kumar dot agarwal at xilinx dot com>
- To: Jeff Law <law at redhat dot com>, Richard Biener <richard dot guenther at gmail dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Cc: Vinod Kathail <vinodk at xilinx dot com>, Shail Aditya Gupta <shailadi at xilinx dot com>, Vidhumouli Hunsigida <vidhum at xilinx dot com>, "Nagaraju Mekala" <nmekala at xilinx dot com>
- Date: Sun, 15 Mar 2015 08:15:36 +0000
- Subject: Short Circuit compiler transformations!!
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=pass (sender IP is 149.199.60.83) smtp dot mailfrom=ajit dot kumar dot agarwal at xilinx dot com; gcc.gnu.org; dkim=none (message not signed) header.d=none;
Hello All:
Short circuit compiler transformation for conditional branches. The conditional branches based on the conditional
Expressions one of the path is always executed thus short circuiting the path. Certains values of the conditional
Expressions makes the conditional expressions always true or false. This part of the conditions in extracted out
In the IF-THEN cond_express with the check of the value and in the else case the original expressions is checked.
This makes for a given values of the variables of the conditional expressions makes the conditional expression as
True or false always and the one path is always executed.
For the example given below.
For( x1 = lb1; x1 < = ub1 ; x1++)
{
If ( C1 && C2)
S_then
}
Fig (1).
For the input code given in Fig (1) the condition C1 && C2 is always false if C1 or C2 is zero(false) thus short circuiting
The path and only s_else will be executed if C1 or C2 is false.
Thus the input code is transformed as follows.
For( x1 = lb1; x1 < = ub1 ; x1++)
{
If(!C1)
Continue
else
S_then
}
This is much simpler code and there could be complex expressions inside the FOR Loop that can be extracted out with
Different versions of the conditional IF-THEN-ELSE inside the loops based on short circuiting executing one of the path always
Executed can be extracted in IF-THEN and other cases of condition will be inside the else conditions.
Again this has to be optimized based on the profile Data of hot conditional branches and the above optimizations is performed
Based on the hotness of the conditional branches.
The short Circuiting optimization also makes the irreducible loops with conditional branches as reducible and there is no need for
Conversion of irreducible loops to reducible loop with any of the existing approach like node splitting for the short circuiting candidate.
This optimizations is implemented in LLVM and I would like to know if this is implemented in GCC. If not implemented I would like
To propose this short circuit compiler transformation.
Thoughts Please ?
Thanks & Regards
Ajit