Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combineVSelectWithAllOnesOrZeros - extend to support X86ISD::BLENDV #53791

Closed
RKSimon opened this issue Feb 12, 2022 · 2 comments
Closed

combineVSelectWithAllOnesOrZeros - extend to support X86ISD::BLENDV #53791

RKSimon opened this issue Feb 12, 2022 · 2 comments

Comments

@RKSimon
Copy link
Collaborator

RKSimon commented Feb 12, 2022

https://llvm.godbolt.org/z/e4hG7cE3q

define void @masked_add(<8 x i32>* %pa, <8 x i32>* %pb, i8 %bitmask) {
  %a = load <8 x i32>, <8 x i32>* %pa, align 32
  %b = load <8 x i32>, <8 x i32>* %pb, align 32
  %m = bitcast i8 %bitmask to <8 x i1>
  %s = select <8 x i1> %m, <8 x i32> %b, <8 x i32> zeroinitializer
  %r = add <8 x i32> %s, %a
  store <8 x i32> %r, <8 x i32>* %pa, align 32
  ret void
}

llc -mcpu=znver2

masked_add: # @masked_add
  vmovdqa .LCPI0_0(%rip), %ymm1 # ymm1 = [1,2,4,8,16,32,64,128]
  vmovd %edx, %xmm0
  vpbroadcastb %xmm0, %ymm0
  vpand %ymm1, %ymm0, %ymm0
  vpcmpeqd %ymm1, %ymm0, %ymm0
  vpxor %xmm1, %xmm1, %xmm1
  vblendvps %ymm0, (%rsi), %ymm1, %ymm0
  vpaddd (%rdi), %ymm0, %ymm0
  vmovdqa %ymm0, (%rdi)
  vzeroupper
  retq

We should be folding away the vblendvps to either and/andnot depending on whether any of the inputs are 0/-1

@llvmbot
Copy link
Member

llvmbot commented Feb 12, 2022

@llvm/issue-subscribers-backend-x86

@RKSimon
Copy link
Collaborator Author

RKSimon commented Nov 27, 2024

This was fixed by f591231

@RKSimon RKSimon closed this as completed Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants