[PATCH] D142602: [X86] Expand transform (icmp eq/ne (ABS A), C) -> (and/or (icmp eq/ne A, C), (icmp eq/ne A, -C))

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 12 13:53:23 PST 2023


goldstein.w.n added a comment.

In D142602#4121358 <https://reviews.llvm.org/D142602#4121358>, @goldstein.w.n wrote:

> In D142602#4121033 <https://reviews.llvm.org/D142602#4121033>, @RKSimon wrote:
>
>> Also I'm curious how well this could work on pre-SSSE3 codegen - where we don't have PABS instructions at all
>
> Pre `ssse3` abs gets the following codegen:
>
>   0000000000000000 <abs_v2i64>:
>      0:	66 0f 6f c8          	movdqa %xmm0,%xmm1
>      4:	66 0f 72 e1 1f       	psrad  $0x1f,%xmm1
>      9:	66 0f 70 c9 f5       	pshufd $0xf5,%xmm1,%xmm1
>      e:	66 0f ef c1          	pxor   %xmm1,%xmm0
>     12:	66 0f fb c1          	psubq  %xmm1,%xmm0
>     16:	c3                   	ret    
>     17:	66 0f 1f 84 00 00 00 	nopw   0x0(%rax,%rax,1)
>     1e:	00 00 
>   
>   0000000000000020 <abs_v4i32>:
>     20:	66 0f 6f c8          	movdqa %xmm0,%xmm1
>     24:	66 0f 72 e1 1f       	psrad  $0x1f,%xmm1
>     29:	66 0f ef c1          	pxor   %xmm1,%xmm0
>     2d:	66 0f fa c1          	psubd  %xmm1,%xmm0
>     31:	c3                   	ret    
>     32:	66 2e 0f 1f 84 00 00 	cs nopw 0x0(%rax,%rax,1)
>     39:	00 00 00 
>     3c:	0f 1f 40 00          	nopl   0x0(%rax)
>   
>   0000000000000040 <abs_v8i16>:
>     40:	66 0f ef c9          	pxor   %xmm1,%xmm1
>     44:	66 0f f9 c8          	psubw  %xmm0,%xmm1
>     48:	66 0f ee c1          	pmaxsw %xmm1,%xmm0
>     4c:	c3                   	ret    
>     4d:	0f 1f 00             	nopl   (%rax)
>   
>   0000000000000050 <abs_v16i8>:
>     50:	66 0f ef c9          	pxor   %xmm1,%xmm1
>     54:	66 0f f8 c8          	psubb  %xmm0,%xmm1
>     58:	66 0f da c1          	pminub %xmm1,%xmm0
>     5c:	c3                   	ret    
>
> Probably makes sense for i64 but for the rest will make this only if the node already exists.

For the time being, think I'm going to drop this commit, doesn't seem to be much gain. Might revisit later.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142602/new/

https://reviews.llvm.org/D142602



More information about the llvm-commits mailing list