[PATCH] D23885: [ThinLTO] add constArgumentsBitmask to caller summary

Easwaran Raman via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 25 16:55:42 PDT 2016


eraman added a comment.

In https://reviews.llvm.org/D23885#525602, @Prazek wrote:

> In https://reviews.llvm.org/D23885#525493, @mehdi_amini wrote:
>
> > Why a bit mask and not an integer with the number of arguments that are constant? 
> >  Do you plan to benefit from knowing which argument is constant?
>
>
> Yes, in order to make better heuristic, like the one that Easwaran come up with
>
> - have some bitmask to say if the argument is compered inside function body as heuristic to determine if branch depends on it. I will need the the information about the arguments.




In https://reviews.llvm.org/D23885#525602, @Prazek wrote:

> In https://reviews.llvm.org/D23885#525493, @mehdi_amini wrote:
>
> > Why a bit mask and not an integer with the number of arguments that are constant? 
> >  Do you plan to benefit from knowing which argument is constant?
>
>
> Yes, in order to make better heuristic, like the one that Easwaran come up with
>
> - have some bitmask to say if the argument is compered inside function body as heuristic to determine if branch depends on it. I will need the the information about the arguments.


More context on this (which was an offline conversation I had with Piotr). One major use of knowing the constant parameters in inline cost analysis is to determine if any branch condition becomes constant and not count the body of blocks that becomes unreachable. One thing we could do is to build a map from conditions based on parameters to number of instructions that become unreachable if the predicate is true. For example,

define i32 @foo(i32 %a)  {
entry:

  %cmp = icmp sgt i32 %a, 10
  br i1 %cmp, label %if.then, label %if.end

if.then:                                          ; preds = %entry
// Lots of instructions here.
if.end:                                           ; preds = %if.then, %entry

  ret i32 %a

}

we could analyze this and map the (a > 10) condition to the potential reduction in instructions. If we were to build something like this, it will be useful to know the constant values of parameters. This patch only keeps track of whether a parameter receives a constant value in some callsite, so it is less information than what would be needed, but better than knowing how many parameters are constants in some context.


https://reviews.llvm.org/D23885





More information about the llvm-commits mailing list