[LLVMbugs] [Bug 23369] New: r235837 broke 8-bit vector multiplies on older x86

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Apr 28 15:58:32 PDT 2015


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

            Bug ID: 23369
           Summary: r235837 broke 8-bit vector multiplies on older x86
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: andrew.b.adams at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

vectorized 8-bit multiplies no longer produce correct results on k8. To repro:

scratch.ll:

define void @test(<16 x i8>* %a, <16 x i8>* %b, <16 x i8>* %c) {
  %1 = load <16 x i8>, <16 x i8>* %a
  %2 = load <16 x i8>, <16 x i8>* %b
  %3 = mul <16 x i8> %1, %2
  store <16 x i8> %3, <16 x i8>* %c
  ret void
}

test.c:

#include <stdint.h>
#include <stdio.h>

void test(uint8_t *a, uint8_t *b, uint8_t *c);

int main(int argc, char **argv) {
  uint8_t a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
  uint8_t b[] = {2, 4, 1, 3,  2, 4, 1, 2,  2, 3, 1, 4,  1, 2, 3, 4};
  uint8_t correct[16];
  for (int i = 0; i < 16; i++) {
    correct[i] = a[i] * b[i];
  }
  uint8_t actual[16];
  test(a, b, actual);
  for (int i = 0; i < 16; i++) {
    printf("%d %d\n", correct[i], actual[i]);
  }

  return 0;
}

Compile scratch.ll two different ways:

llc -O3 scratch.ll -mcpu=penryn -filetype=obj -o scratch_penryn.o
llc -O3 scratch.ll -mcpu=k8 -filetype=obj -o scratch_k8.o

Make two binaries:

clang test.c scratch_penryn.o -o test_penryn
clang test.c scratch_k8.o -o test_k8

Run them:

test_penryn:

2 2
8 8
3 3
12 12
10 10
24 24
7 7
16 16
18 18
30 30
11 11
48 48
13 13
28 28
45 45
64 64

The columns match, this is correct.

test_k8:

2 1
8 4
3 9
12 16
10 25
24 36
7 49
16 64
18 18
30 30
11 11
48 48
13 13
28 28
45 45
64 64

The multiply only happened for the second half of the lanes. For the first half
of the lanes it just passes through the input.

-- 
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/20150428/83bc586d/attachment.html>


More information about the llvm-bugs mailing list