[llvm-dev] Use case for function unswitching.
raghesh via llvm-dev
llvm-dev at lists.llvm.org
Fri Jun 7 01:33:11 PDT 2019
Dear All,
It would be great if anyone help me out in finding a use case similar to
the following example.
__attribute__((noinline))
int f (int p) {
if (p == 10) { // if-1
return 0;
}
// Some statements here.
return 2;
}
int g(int p) {
return f(p);
}
Here, I would like to see if the compiler does a transformation, where the
if statement (if-1) in the body of the function 'f' is removed from 'f' and
pushed to the caller 'g' as follows. Please note that I have forced not to
inline 'f'.
int f (int p) {
// Some statements here.
return 2;
}
int g(int p) {
if (p == 10) { // if-1
return 0;
}
return f(p);
}
This is a simple example that I used just to demonstrate the optimization
(we may call it as function switching). If you know about any other use
cases, where similar transformation happens, please let me know. When I
generated the llvm IR (with -O3) such a transformation was not observed.
Regards,
--
Raghesh Aloor
PhD Scholar
PACE Lab, Dept. of CSE, IIT Madras
http://www.cse.iitm.ac.in/~raghesh/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190607/00cc3633/attachment.html>
More information about the llvm-dev
mailing list