This is the mail archive of the 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]

RE: Short Circuit compiler transformations!!

-----Original Message-----
From: Richard Biener [] 
Sent: Sunday, March 15, 2015 3:05 PM
To: Ajit Kumar Agarwal; Jeff Law;
Cc: Vinod Kathail; Shail Aditya Gupta; Vidhumouli Hunsigida; Nagaraju Mekala
Subject: Re: Short Circuit compiler transformations!!

On March 15, 2015 9:15:36 AM GMT+01:00, Ajit Kumar Agarwal <> wrote:
>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 looks wrong as you miss to check C2.

Riichard: Sorry for the typo error. I could see the short circuit transformation is implemented in gcc. I could see only
Short circuiting with respect to &&/OR. I am thinking in terms of complex expressions where any of the variable condition
In the expressions Set to to true or false the whole expressions and such conditions can be extracted out into different versions
of IF with different parameter check( Another way of short circuiting).

I would like to know the scope of this optimization in gcc. If not implemented with respect to complex expressions with respect
To different iteration spaces. I would like to propose the same.

Thoughts Please?

Thanks & Regards


>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

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