[llvm-bugs] [Bug 38522] New: Inefficient code generation for v16i8 vertical less-equal
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Aug 10 10:14:43 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38522
Bug ID: 38522
Summary: Inefficient code generation for v16i8 vertical
less-equal
Product: new-bugs
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: gonzalobg88 at gmail.com
CC: chandlerc at gmail.com, hfinkel at anl.gov,
llvm-bugs at lists.llvm.org, llvm-dev at redking.me.uk,
spatel+llvm at rotateright.com
The following Rust program:
extern crate packed_simd;
use packed_simd::*;
pub fn le_i8x16(x: i8x16, y: i8x16) -> bool {
x.le(y).all()
}
when compiled with AVX2 and O3 (RUSTFLAGS="-C target-feature=+avx2") generates
the following LLVM-IR (https://godbolt.org/g/R2zra8) and assembly:
declare i32 @llvm.x86.sse41.ptestc(<2 x i64>, <2 x i64>);
define zeroext i1 @le_i8x16(<16 x i8>* %x, <16 x i8>* %y) {
start:
%0 = load <16 x i8>, <16 x i8>* %x, align 16
%1 = load <16 x i8>, <16 x i8>* %y, align 16
%2 = icmp sle <16 x i8> %0, %1
%3 = sext <16 x i1> %2 to <16 x i8>
%4 = bitcast <16 x i8> %3 to <2 x i64>
%5 = tail call i32 @llvm.x86.sse41.ptestc(<2 x i64> %4, <2 x i64> <i64 -1, i64
-1>)
%6 = icmp eq i32 %5, 1
ret i1 %6
}
packed_simd_iter::le_i8x16:
push rbp
mov rbp, rsp
vmovdqa xmm0, xmmword, ptr, [rdi]
vpcmpgtb xmm0, xmm0, xmmword, ptr, [rsi]
vpcmpeqd xmm1, xmm1, xmm1
vpxor xmm0, xmm0, xmm1
vptest xmm0, xmm1
setb al
pop rbp
ret
Note that Rust generates IR for a vertical <= vector-vector operation which
returns a mask, and then IR for the all reduction.
The assembly we would expect is:
pushq %rbp
movq %rsp, %rbp
vmovdqa (%rdi), %xmm0
vpcmpgtb (%rsi), %xmm0, %xmm0
vptest %xmm0, %xmm0
sete %al
popq %rbp
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/20180810/0be3f8c4/attachment-0001.html>
More information about the llvm-bugs
mailing list