[llvm-bugs] [Bug 26697] New: [x86, AVX] simplify masked memop's mask operand

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 22 09:07:07 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26697

            Bug ID: 26697
           Summary: [x86, AVX] simplify masked memop's mask operand
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

I mentioned this in http://reviews.llvm.org/D17485 : the vector type of the
mask differs between the LLVM and x86 versions of masked memops. If we
recognize the pattern(s) needed for that conversion in the DAG, I think we can
eliminate the x86-specific masked memop intrinsic defs completely by converting
all of those to *LLVM* masked memop intrinsics:

declare void @llvm.masked.store.v4f32(<4 x float> %val, <4 x float>* %addr,
i32, <4 x i1> %maskb2)

define void @one_mask_bit_set1(<4 x float>* %addr, <4 x float> %val, <4 x i32>
%mask) {
  %mask_signbit = and <4 x i32> %mask, <i32 2147483648, i32 2147483648, i32
2147483648, i32 2147483648>
  %mask_bool = icmp ne <4 x i32> %mask_signbit, zeroinitializer
  call void @llvm.masked.store.v4f32(<4 x float> %val, <4 x float>* %addr, i32
1, <4 x i1> %mask_bool)
  ret void
}

This should be:
    vmaskmovps    %xmm0, %xmm1, (%rdi)

Ie, the sign bit of each mask element is all that the x86 HW uses as the
selector. Currently, we don't know that so we get this mess:

$ ./llc llvm.maskm.ll -o - -mattr=avx
...
LCPI0_0:
    .long    2147483648              ## 0x80000000
    .long    2147483648              ## 0x80000000
    .long    2147483648              ## 0x80000000
    .long    2147483648              ## 0x80000000
    .section    __TEXT,__text,regular,pure_instructions
    .globl    _one_mask_bit_set1
    .p2align    4, 0x90
_one_mask_bit_set1:                     ## @one_mask_bit_set1
    .cfi_startproc
## BB#0:
    vpand    LCPI0_0(%rip), %xmm1, %xmm1
    vpxor    %xmm2, %xmm2, %xmm2
    vpcmpeqd    %xmm2, %xmm1, %xmm1
    vpcmpeqd    %xmm2, %xmm2, %xmm2
    vpxor    %xmm2, %xmm1, %xmm1
    vmaskmovps    %xmm0, %xmm1, (%rdi)
    retq

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160222/baa81915/attachment.html>


More information about the llvm-bugs mailing list