[LLVMdev] Shuffle combine

Nicolas Capens nicolas at capens.net
Wed Apr 1 04:34:08 PDT 2009


Hi all,

 

I'm having some trouble understanding the following lines in
InstructionCombining.cpp, which possibly contain a bug:

 

if (Mask[i] >= 2*e)

    NewMask.push_back(2*e);

else

    NewMask.push_back(LHSMask[Mask[i]]);

 

When Mask[i] is bigger than the size of LHSMask it reads out of bounds on
that last line. I believe the first line is there to try to prevent that but
then it should be comparing to LHSMask.size() not 2*e (e being Mask.size()).
And when Mask[i] is bigger than the mask size the shuffle combine won't work
anyway so I would replace these lines with:

 

if (Mask[i] >= LHSMask.size())

    break;

else

    NewMask.push_back(LHSMask[Mask[i]]);

 

But I'm not sure if I fully understand the implications. Could someone check
this for me and possibly patch it?

 

Thanks,

 

Nicolas

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090401/060c6c6c/attachment.html>


More information about the llvm-dev mailing list