[LLVMdev] Question on SelectionDAGBuilder

Dan Gohman gohman at apple.com
Tue Mar 30 16:46:45 PDT 2010


On Mar 30, 2010, at 3:54 PM, David Greene wrote:
> 
> In SelectionDAGBuilder::visitShuffleVector there's some code to see if we can
> convert the shuffle to an EXTRACT_SUBVECTOR.  After computing min/max
> values of the mask for each operand, there's a look that looks at the ranges
> and determines whether an EXTRACT_SUBVECTOR can be used:
> 
>    for (int Input=0; Input < 2; ++Input) {
>      if (MinRange[Input] == (int)(SrcNumElts+1) && MaxRange[Input] == -1) {
>        RangeUse[Input] = 0; // Unused
>        StartIdx[Input] = 0;
>      } else if (MaxRange[Input] - MinRange[Input] < (int)MaskNumElts) {
>        // Fits within range but we should see if we can find a good
>        // start index that is a multiple of the mask length.
>        if (MaxRange[Input] < (int)MaskNumElts) {
>          RangeUse[Input] = 1; // Extract from beginning of the vector
>          StartIdx[Input] = 0;
>        } else {
>          StartIdx[Input] = (MinRange[Input]/MaskNumElts)*MaskNumElts;
>          if (MaxRange[Input] - StartIdx[Input] < (int)MaskNumElts &&
>              StartIdx[Input] + MaskNumElts < SrcNumElts)
>            RangeUse[Input] = 1; // Extract from a multiple of the mask 
> length.
>        }
>      }
>    }
> 
> Should this line:
> 
>              StartIdx[Input] + MaskNumElts < SrcNumElts)
> 
> 
> use <= rather than <?

Yes, it looks that way to me.

Dan





More information about the llvm-dev mailing list