[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
Thu May 30 07:04:26 PDT 2013


Hi Rafael,

Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote on 29/05/2013 
20:18:46:

> The testcases take and return scalars that are bitcast to and from a
> vector. For example, you have:
> 
> define i32 @AddToSelf_i8(i32 %InVec)  {
> entry:
>   %0 = bitcast i32 %InVec to <4 x i8>
>   %mul = mul <4 x i8> %0, <i8 2, i8 2, i8 2, i8 2>
>   %1 = bitcast <4 x i8> %mul to i32
>   ret i32 %1
> }
> 
> Why not the simpler:
> 
> define <4 x i8> @AddToSelf_i8(<4 x i8> %InVec)  {
> entry:
>   %mul = mul <4 x i8> %InVec, <i8 2, i8 2, i8 2, i8 2>
>   ret <4 x i8> %mul
> }
> 
> A really small nit is that you don't need the "-o -" in the command
> line, opt will print to stdout when reading from stdin.
> 

I simplified the test case removing all the unnecessary bitcasts.
The test case now definitely looks better, thanks for the feedback!
I also removed the "-o -" in the command line as you suggested.

> The current style is to start function names with lower case and they
> should be verb phrases
> (http://llvm.org/docs/CodingStandards.html#name-types-functions-
> variables-and-enumerators-properly),
> so please use something like getLogBase2Vector.
> 
> It looks like the function is only ever used with ConstantDataVector,
> so please use
> 
> static Constant *getLogBase2Vector(const ConstantDataVector *C)
> 
> as the signature and simplify.

True, sorry about that..
I renamed the function into `getLogBase2Vector' and I simplified the body 
of that
function since now it expects a ConstantDataVector in input.

The updated patch can be found in attachment to this email.

P.s.: I forgot to mention on my initial post that I don't have
commit access to the repository.

Thanks,
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-instcombine.diff
Type: application/octet-stream
Size: 13991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130530/1b04ca45/attachment.obj>


More information about the llvm-commits mailing list