[PATCH] X86: fold SSE2/AVX2 logical shift by immediate amout into zero vector when possible

Andrea_DiBiagio at sn.scee.net Andrea_DiBiagio at sn.scee.net
Fri Jul 12 10:39:11 PDT 2013


> From: Duncan Sands <duncan.sands at gmail.com>
> Hi Andrea,
> 
> On 12/07/13 15:57, Andrea_DiBiagio at sn.scee.net wrote:
> > Hi,
> > I attached the patch against the most recent tot.
> > Could you please commit this patch for me? (I have no commit access)
> 
> I don't understand why this is an X86 specific combine rather than a 
general
> one in the DAG combiner.
> 
> Ciao, Duncan.

The main reason why I decided to implement it as a X86 specific combine is 
because I didn't feel comfortable with implementing it as a general one. 
That is because I don't know enough about how vector shifts are handled by 
other targets in the case where the count operand exceeds the vector 
element size.

Since the current implementation matches exactly the expected behavior of 
SSE2/AVX2 vector shifts, to be on the safe side I thought that it was 
reasonable to make it x86 specific only. For example, in the case of 
vector shift by immediate amount, the shift amount is encoded in 8-bits. 
The combine implicitly truncates the amount to 8 to mimic the target 
behavior.

Example:
////
  __m128i InVec = { 4, 4 };
  __m128i result = _mm_slli_epi64(InVec, 1024);    // this will generate a 
psllw $1024, %xmm0
  printf( "[%lld %lld]\n", result[0], result[1]);  // this will print out 
"[ 4, 4 ]"
////

Andrea Di Biagio
SN Systems - Sony Computer Entertainment Group

**********************************************************************
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



More information about the llvm-commits mailing list