[llvm-dev] Conditional analysis before inliner

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] Conditional analysis before inliner

Dean Michael Berris via llvm-dev
Hi,

I have pass phase ordering question. 

I am interested in performing a transformation that matches several LLVM IR instructions and converts them to a single builtin. This sort of transformation must occur prior to inlining because inlining needs to analyze cost of the builtin. However, the LLVM IR -> builtin transformation requires scalar evolution which typically doesn't run until after the inliner.

My question is, is there a way to run scalar evolution conditionally prior to inlining? I'd like to leave compile time unaffected if my code doesn't contain any of these builtins.

Thanks,

Stan

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Conditional analysis before inliner

Dean Michael Berris via llvm-dev
On 4/19/2018 1:57 PM, Anom LLVM via llvm-dev wrote:

> Hi,
>
> I have pass phase ordering question.
>
> I am interested in performing a transformation that matches several
> LLVM IR instructions and converts them to a single builtin. This sort
> of transformation must occur prior to inlining because inlining needs
> to analyze cost of the builtin. However, the LLVM IR -> builtin
> transformation requires scalar evolution which typically doesn't run
> until after the inliner.

This isn't right, or at least, not the complete picture; loop
optimization passes run interleaved with the inliner.  (Try looking at
the output of "-debug-pass=Executions" to see exactly what's happening.)

> My question is, is there a way to run scalar evolution conditionally
> prior to inlining? I'd like to leave compile time unaffected if my
> code doesn't contain any of these builtins.

ScalarEvolution is lazy, so it's essentially free if you don't query it.

-Eli

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Conditional analysis before inliner

Dean Michael Berris via llvm-dev
Thanks for the answer Eli.

I think I was a little too vague in my question. The program has the following structure:
void foo() {
  bar();
}

void bar() {
  for (..) {
       __builtin_compute()
  }
}

We would like to use scalar evolution + loopinfowrapperpass inside instcombine only if __builtin_compute is present. instcombine can convert the loop into a single builtin ie.

void bar() {
  __builtin_wide_compute();
}

When the inliner runs on foo(), we want bar() to already have the transformation to reflect the cost of the inlining decision more accurately. 

I do see that scalar evolution is a lazy but loopwrapinfopass is not. Is there a way to run these two analysis passes conditionally before inlining?

Thanks,

Stan






On Fri, Apr 20, 2018 at 1:55 PM, Friedman, Eli <[hidden email]> wrote:
On 4/19/2018 1:57 PM, Anom LLVM via llvm-dev wrote:
Hi,

I have pass phase ordering question.

I am interested in performing a transformation that matches several LLVM IR instructions and converts them to a single builtin. This sort of transformation must occur prior to inlining because inlining needs to analyze cost of the builtin. However, the LLVM IR -> builtin transformation requires scalar evolution which typically doesn't run until after the inliner.

This isn't right, or at least, not the complete picture; loop optimization passes run interleaved with the inliner.  (Try looking at the output of "-debug-pass=Executions" to see exactly what's happening.)

My question is, is there a way to run scalar evolution conditionally prior to inlining? I'd like to leave compile time unaffected if my code doesn't contain any of these builtins.

ScalarEvolution is lazy, so it's essentially free if you don't query it.

-Eli

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Conditional analysis before inliner

Dean Michael Berris via llvm-dev
I probably wouldn't worry about the cost of LoopInfo; it's relatively cheap to compute.  But if you're really concerned, you can run your pass after a pass which preserves LoopInfo (so it's free because it was already computed).  Or you can stick your code into an existing pass which requires LoopInfo anyway, like LoopIdiomRecognize.

-Eli

On 4/23/2018 3:37 PM, Anom LLVM wrote:
Thanks for the answer Eli.

I think I was a little too vague in my question. The program has the following structure:
void foo() {
  bar();
}

void bar() {
  for (..) {
       __builtin_compute()
  }
}

We would like to use scalar evolution + loopinfowrapperpass inside instcombine only if __builtin_compute is present. instcombine can convert the loop into a single builtin ie.

void bar() {
  __builtin_wide_compute();
}

When the inliner runs on foo(), we want bar() to already have the transformation to reflect the cost of the inlining decision more accurately. 

I do see that scalar evolution is a lazy but loopwrapinfopass is not. Is there a way to run these two analysis passes conditionally before inlining?

Thanks,

Stan






On Fri, Apr 20, 2018 at 1:55 PM, Friedman, Eli <[hidden email]> wrote:
On 4/19/2018 1:57 PM, Anom LLVM via llvm-dev wrote:
Hi,

I have pass phase ordering question.

I am interested in performing a transformation that matches several LLVM IR instructions and converts them to a single builtin. This sort of transformation must occur prior to inlining because inlining needs to analyze cost of the builtin. However, the LLVM IR -> builtin transformation requires scalar evolution which typically doesn't run until after the inliner.

This isn't right, or at least, not the complete picture; loop optimization passes run interleaved with the inliner.  (Try looking at the output of "-debug-pass=Executions" to see exactly what's happening.)

My question is, is there a way to run scalar evolution conditionally prior to inlining? I'd like to leave compile time unaffected if my code doesn't contain any of these builtins.

ScalarEvolution is lazy, so it's essentially free if you don't query it.

-Eli

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Conditional analysis before inliner

Dean Michael Berris via llvm-dev
I do not think we have this framework of conditionally kicking in analysis passes. But one can always do "intelligent" prior setting of attribute over function which can be checked in getAnalysisUsage for a perticular pass to conditionally enable needed analysis.

Cheers
Jatin 

On Tue, 24 Apr 2018, 04:33 Friedman, Eli via llvm-dev, <[hidden email]> wrote:
I probably wouldn't worry about the cost of LoopInfo; it's relatively cheap to compute.  But if you're really concerned, you can run your pass after a pass which preserves LoopInfo (so it's free because it was already computed).  Or you can stick your code into an existing pass which requires LoopInfo anyway, like LoopIdiomRecognize.

-Eli

On 4/23/2018 3:37 PM, Anom LLVM wrote:
Thanks for the answer Eli.

I think I was a little too vague in my question. The program has the following structure:
void foo() {
  bar();
}

void bar() {
  for (..) {
       __builtin_compute()
  }
}

We would like to use scalar evolution + loopinfowrapperpass inside instcombine only if __builtin_compute is present. instcombine can convert the loop into a single builtin ie.

void bar() {
  __builtin_wide_compute();
}

When the inliner runs on foo(), we want bar() to already have the transformation to reflect the cost of the inlining decision more accurately. 

I do see that scalar evolution is a lazy but loopwrapinfopass is not. Is there a way to run these two analysis passes conditionally before inlining?

Thanks,

Stan






On Fri, Apr 20, 2018 at 1:55 PM, Friedman, Eli <[hidden email]> wrote:
On 4/19/2018 1:57 PM, Anom LLVM via llvm-dev wrote:
Hi,

I have pass phase ordering question.

I am interested in performing a transformation that matches several LLVM IR instructions and converts them to a single builtin. This sort of transformation must occur prior to inlining because inlining needs to analyze cost of the builtin. However, the LLVM IR -> builtin transformation requires scalar evolution which typically doesn't run until after the inliner.

This isn't right, or at least, not the complete picture; loop optimization passes run interleaved with the inliner.  (Try looking at the output of "-debug-pass=Executions" to see exactly what's happening.)

My question is, is there a way to run scalar evolution conditionally prior to inlining? I'd like to leave compile time unaffected if my code doesn't contain any of these builtins.

ScalarEvolution is lazy, so it's essentially free if you don't query it.

-Eli

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev