On 08/26/2015 05:13 AM, Ilya Enkovich wrote:
2015-08-26 0:42 GMT+03:00 Jeff Law <l...@redhat.com>:
On 08/21/2015 04:49 AM, Ilya Enkovich wrote:
I want a work with bitmasks to be expressed in a natural way using
regular integer operations. Currently all masks manipulations are
emulated via vector statements (mostly using a bunch of vec_cond). For
complex predicates it may be nontrivial to transform it back to scalar
masks and get an efficient code. Also the same vector may be used as
both a mask and an integer vector. Things become more complex if you
additionally have broadcasts and vector pack/unpack code. It also
should be transformed into a scalar masks manipulations somehow.
Or why not model the conversion at the gimple level using a CONVERT_EXPR?
In fact, the more I think about it, that seems to make more sense to me.
We pick a canonical form for the mask, whatever it may be. We use that
canonical form and model conversions between it and the other form via
CONVERT_EXPR. We then let DOM/PRE find/eliminate the redundant conversions.
If it's not up to the task, we should really look into why and resolve.
Yes, that does mean we have two forms which I'm not terribly happy about and
it means some target dependencies on what the masked vector operation looks
like (ie, does it accept a simple integer or vector mask), but I'm starting
to wonder if, as distasteful as I find it, it's the right thing to do.
If we have some special representation for masks in GIMPLE then we
might not need any conversions. We could ask a target to define a MODE
for this type and use it directly everywhere: directly compare into
it, use it directly for masked loads and stores, AND, IOR, EQ etc. If
that type is reserved for masks usage then you previous suggestion to
transform masks into target specific form at GIMPLE->RTL phase should
work fine. This would allow to support only a single masks
representation in GIMPLE.
Possibly, but you mentioned that you may need to use the masks in both
forms depending on the exact context. If so, then I think we need to
model a conversion between the two forms.
Jeff