[LLVMdev] Upstream PTX backend that uses target independent code generator if possible

David A. Greene greened at obbligato.org
Thu Aug 26 15:01:26 PDT 2010

Che-Liang Chiou <clchiou at gmail.com> writes:

>> The one thing we'll have to add is mask support.
> I'm a little bit confused here.  Does "masked operation" equal to
> "predicated operation"?

Yep.  "Mask" is the traditional vector term since the predicates for
each element can be different.

>>> * Masked operation, as well as branch folding and alike, is much
>>> easier to implement in codegen approach.  I am not sure how much
>>> performance improvement could be achieved from these optimizations,
>>> but it is worth trying.
>> I'm not sure why these would be easier with one model over another.
>> It's a lot of hand-lowering and manual optimization either way.  Can you
>> explain?
> The codegen is smart enough to translate a simple if-else block like
>   if (pred) return A; else return B;
> into one instruction
>   selp A, B, pred

That's a really simple case.  The general case is much more involved.
It has to handle multiple levels of branching.  It can be done pretty
mechanically, but it all has to be hand-coded in LLVM.  

There are really two things going on here.  The first is the ability to
take branchy code and if-convert it.  That's usually pretty
straightforward for the common cases.  The second is handling code
that's already in predicated form.  Since right now there's no publicly
available vectorizer with mask support for LLVM, we aren't going to see
that for a while.  This kind of thing really calls for an extension to
the LLVM IR to handle general predication.

The ARM target codegen may or may not be a good place to look.  I don't
know how involved its predication is.

> Also codegen has branch-folding support so it would be easier (this is
> my guess, I've not yet started).

Ok, that's probably true.

> By the way, what should I do to upstream this backend?  I submitted a
> small patch to llvm-commits mailing list.  In average how long I have
> to wait for code review?  Thanks.

I must have missed it.  Can you send it again?


More information about the llvm-dev mailing list