[PATCH] Teach instcombine how to combine multiply of constant splat of known power-of-2

Andrea_DiBiagio at sn.scee.net Andrea_DiBiagio at sn.scee.net
Wed May 29 04:05:53 PDT 2013


Hi,

Here is an updated patch that deals with the general case where a multiply 
by a vector of constants known
power-of-2 are combined into shifts.
My original patch only allowed combining multiply by splat of known 
constant powers of 2.

Thanks,
Andrea Di Biagio
SN Systems - Sony Computer Entertainment Group



Andrea DiBiagio/SN R&D/BS/UK/SCEE wrote on 24/05/2013 13:46:41:

> Hi Rafael,
> 
> Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote on 23/05/2013 
18:13:29:
> 
> > you explicitly test that things like
> > 
> > define i32 @MulTest3_i8(i32 %InVec)  {
> > entry:
> >   %0 = bitcast i32 %InVec to <4 x i8>
> >   %mul = mul <4 x i8> %0, <i8 4, i8 4, i8 2, i8 2>
> >   %1 = bitcast <4 x i8> %mul to i32
> >   ret i32 %1
> > }
> > 
> > are not optimized. Why is it not profitable to use
> > 
> > shl <4 x i8> %0, <i8 2, i8 2, i8 1, i8 1>
> > 
> > ?

> My original test simply tried to verify that multiply by constant 
> splats of known 
> power-of-2 were correctly optimized into shifts.
> However, I think that converting a mul into a shift is profitable even 
in the
> case you reported and probably my patch should be rewritten to 
> address the general case
> (i.e. not only the case of constant splats).
> 
> I will update this thread as soon as I have a new patch available.

**********************************************************************
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 --------------
A non-text attachment was scrubbed...
Name: patch-instcombine.diff
Type: application/octet-stream
Size: 16129 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130529/e44644a8/attachment.obj>


More information about the llvm-commits mailing list