[PATCH] X86 Builtins: rewrite SSE2/AVX2 shift builtin intrinsics using shift operators

Andrea_DiBiagio at sn.scee.net Andrea_DiBiagio at sn.scee.net
Wed Jul 17 11:51:50 PDT 2013


> From: Eli Friedman <eli.friedman at gmail.com>
> On Wed, Jul 17, 2013 at 10:44 AM,  <Andrea_DiBiagio at sn.scee.net> wrote:
> > Hi all,
> >
> > I'd like to contribute a patch that rewrites (most of the) X86
> > SSE2/AVX2 packed shifts builtin intrinsics using shift operators.
> 
> No.  They don't have the same semantics in the boundary cases.  (From
> LangRef for lshr: "If op2 is (statically or dynamically) equal to or
> larger than the number of bits in op1, the result is undefined.")
> 
> -Eli

True...

I think the only reason why it was working for me is because the 
shift-count-overflow is only spotted by the optimizer in the case of 
scalar shifts.
clang warns about shift-count-overflow in the case of scalar shifts and 
the optimizer correctly propagates undef in that case. However that does 
not seem to happen in the case of vector shifts.

//////////
typedef int int4 __attribute__((ext_vector_type(4)))

int4 foo(int4 op1) {
  return op1 << (int4){300,300,300,300};
}

int bar(int op1) {
  return op1 << 300;
}
/////
At -O1
function `bar' is optimized into
ret i32 undef

However the shift instruction in `foo' is not replaced:

%shl = shl <4 x i32> %op1, <i32 300, i32 300, i32 300, i32 300>

Anyway..
thanks for the feedback and sorry for the wrong patch.

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 cfe-commits mailing list