[PATCH] Fix for wrong instcombine on vector insert/extract

Andrea_DiBiagio at sn.scee.net Andrea_DiBiagio at sn.scee.net
Fri Mar 22 12:53:00 PDT 2013


Hello,

I would like to contribute a fix for a wrong transformation performed 
by the Instruction Combiner on sequences of insertelement/extractelement 
instructions.

When trying to collapse sequences of insertelement/extractelement
instructions into single shuffle instructions, there is one specific
case where the Instruction Combiner wrongly updates the resulting
Mask of shuffle indexes.

The problem is in function CollectShuffleElments.

If we have a sequence of insert/extract element instructions
like the one below:

  %tmp1 = extractelement <4 x float> %LHS, i32 0
  %tmp2 = insertelement <4 x float> %RHS, float %tmp1, i32 1
  %tmp3 = extractelement <4 x float> %RHS, i32 2
  %tmp4 = insertelement <4 x float> %tmp2, float %tmp3, i32 3

Where:
 . %RHS will have a mask of [4,5,6,7]
 . %LHS will have a mask of [0,1,2,3] 

The Mask of shuffle indexes is wrongly computed to [4,1,6,7]
instead of [4,0,6,7].
When analyzing %tmp2 in order to compute the Mask for the 
resulting shuffle instruction, the algorithm forgets to update
the mask index at position 1 with the index associated to the
element extracted from %LHS by instruction %tmp1.

The patch in attachment fixes the problem with the wrong
propagation of shuffle indexes.
It also adds two extra cases to test 
Transforms/InstCombine/vec_shuffle.ll to check that now we
do the correct thing when collapsing sequences of insert/extract
element instruction in that problematic scenario.



Thanks!
Andrea Di Biagio

**********************************************************************
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. 
If you have received this email in error please notify postmaster at scee.net
This footnote also confirms that this email message has been checked for 
all known viruses.
Sony Computer Entertainment Europe Limited
Registered Office: 10 Great Marlborough Street, London W1F 7LP, United 
Kingdom
Registered in England: 3277793
**********************************************************************

P Please consider the environment before printing this e-mail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130322/fb712030/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: InstCombinePatch.diff
Type: application/octet-stream
Size: 2382 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130322/fb712030/attachment.obj>


More information about the llvm-commits mailing list