[PATCH] D97360: [TTI] Consider select form of and/or i1 as having arithmetic cost
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 1 08:26:42 PST 2021
aqjune added a comment.
In D97360#2594315 <https://reviews.llvm.org/D97360#2594315>, @spatel wrote:
> Thanks - IIUC, we're also going to need to some codegen changes to avoid regressions. For example (the icmps are to avoid diffs due to lack of signext/zeroext specifiers on parameters with vector type):
>
> define <4 x i1> @b(<4 x i32> %x, <4 x i32> %y) {
> %c1 = icmp eq <4 x i32> %x, <i32 42, i32 42, i32 42, i32 42>
> %c2 = icmp sgt <4 x i32> %y, <i32 42, i32 42, i32 42, i32 42>
> %s = select <4 x i1> %c1, <4 x i1> <i1 true, i1 true, i1 true, i1 true>, <4 x i1> %c2
> ret <4 x i1> %s
> }
> define <4 x i1> @b2(<4 x i32> %x, <4 x i32> %y) {
> %c1 = icmp eq <4 x i32> %x, <i32 42, i32 42, i32 42, i32 42>
> %c2 = icmp sgt <4 x i32> %y, <i32 42, i32 42, i32 42, i32 42>
> %s = or <4 x i1> %c1, %c2
> ret <4 x i1> %s
> }
>
>
>
> $ llc -o - logical.ll -mattr=avx -mtriple=x86_64--
> _b: ## @b
> vmovdqa LCPI2_0(%rip), %xmm2 ## xmm2 = [42,42,42,42]
> vpcmpeqd %xmm2, %xmm0, %xmm0
> vpcmpgtd %xmm2, %xmm1, %xmm1
> vblendvps %xmm0, LCPI2_1(%rip), %xmm1, %xmm0
> retq
> _b2: ## @b2
> vmovdqa LCPI3_0(%rip), %xmm2 ## xmm2 = [42,42,42,42]
> vpcmpeqd %xmm2, %xmm0, %xmm0
> vpcmpgtd %xmm2, %xmm1, %xmm1
> vpor %xmm1, %xmm0, %xmm0
> retq
Thank you for the info..!
I'll check whether regression happens with different targets as well and make patches if any.
select form of and/or operations are eagerly folded by InstCombine currently, so they'll look good hopefully.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97360/new/
https://reviews.llvm.org/D97360
More information about the llvm-commits
mailing list