[PATCH] D51207: Introduce llvm.experimental.widenable_condition intrinsic
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 29 20:19:19 PST 2018
On Thu, Nov 29, 2018 at 7:46 PM Max Kazantsev via Phabricator
<reviews at reviews.llvm.org> wrote:
>
> mkazantsev added a comment.
>
> In D51207#1312345 <https://reviews.llvm.org/D51207#1312345>, @apilipenko wrote:
>
> > One of the alternatives naming schemes which was discussed is to call this intrinsic `should_deoptimize`. In this case the meaning of the returned value is inverted, so we need to or it with the condition which we want to widen.
>
>
> Current definition in LangRef gives it much wider use cases than this. The point is, we have no obligation to *only* use this intrinsic in `and` condition with deopt in one of branches. For example, this usage is legit:
>
> if (wc()) {
> // Apply some solution that is fast on small data
> } else {
> // Apply another alternative solution that is fast on big data
> }
>
> No deoptimize at all, but it is OK to make various optimizations that will play with heuristics when to choose which.
Another possibility is:
if (wc()) {
y = easy_to_constant_fold(x);
} else {
// Perhaps uses a lookup table that's difficult to constant fold, but is fast.
y = faster_at_runtime(x);
}
If `x` is constant then LLVM can be smart and choose true for wc()
(avoiding any work at all during runtime) otherwise it can choose
false.
-- Sanjoy
>
>
> CHANGES SINCE LAST ACTION
> https://reviews.llvm.org/D51207/new/
>
> https://reviews.llvm.org/D51207
>
>
>
More information about the llvm-commits
mailing list