[llvm-bugs] [Bug 37396] New: [AVX512] Incorrect register argument to test instruction

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 9 12:10:41 PDT 2018


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

            Bug ID: 37396
           Summary: [AVX512] Incorrect register argument to test
                    instruction
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: keno at alumni.harvard.edu
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org

Consider the following bugpoint-reduced reproducer of
https://github.com/JuliaLang/julia/issues/27032:

```
define void @japi1_foo2_34617() {
pass2:                                            ; preds = %top
  br label %if5

L174:                                             ; preds = %if5
  %tmp = icmp sgt <2 x i64> undef, zeroinitializer
  %tmp1 = icmp sle <2 x i64> undef, undef
  %tmp2 = and <2 x i1> %tmp, %tmp1
  %tmp3 = extractelement <2 x i1> %tmp2, i32 0
  %tmp4 = extractelement <2 x i1> %tmp2, i32 1
  %tmp106 = and i1 %tmp4, %tmp3
  %tmp107 = zext i1 %tmp106 to i8
  %tmp108 = and i8 %tmp122, %tmp107
  %tmp109 = icmp eq i8 %tmp108, 0
  br i1 %tmp109, label %L188, label %L190

if5:                                              ; preds = %if5, %pass2
  %b.055 = phi i8 [ 1, %pass2 ], [ %tmp122, %if5 ]
  %tmp118 = icmp sgt i64 undef, 0
  %tmp119 = icmp sle i64 undef, undef
  %tmp120 = and i1 %tmp118, %tmp119
  %tmp121 = zext i1 %tmp120 to i8
  %tmp122 = and i8 %b.055, %tmp121
  br i1 undef, label %L174, label %if5

L188:                                             ; preds = %L174
  unreachable

L190:                                             ; preds = %L174
  ret void
}
```

Running llc on trunk (and 6.0) gives:
```
$ llc -mcpu=skylake-avx512 bug.ll -o -
        .text
        .file   "wip.ll"
        .globl  japi1_foo2_34617        # -- Begin function japi1_foo2_34617
        .p2align        4, 0x90
        .type   japi1_foo2_34617, at function
japi1_foo2_34617:                       # @japi1_foo2_34617
        .cfi_startproc
# %bb.0:                                # %L174
        testq   %rax, %rax
        setg    %al
        vpxor   %xmm0, %xmm0, %xmm0
        vpcmpgtq        %xmm0, %xmm0, %k0
        kshiftrw        $1, %k0, %k1
        kandd   %k0, %k1, %k0
        testb   %k0, %al
        je      .LBB0_1
# %bb.2:                                # %L190
        retq
.LBB0_1:                                # %L188
.Lfunc_end0:
        .size   japi1_foo2_34617, .Lfunc_end0-japi1_foo2_34617
        .cfi_endproc
                                        # -- End function

        .section        ".note.GNU-stack","", at progbits
```

llvm-mc says it best:
```
$ llvm-mc bug.s
bug.s:15:8: error: invalid operand for instruction
        testb   %k0, %al
                ^~~
```

If we try to generate code directly rather than go through textual assembly,
we end up generating `testb %al, %al`, which was the cause of the above linked
bug report.

-- 
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/20180509/9580f316/attachment.html>


More information about the llvm-bugs mailing list