[llvm-bugs] [Bug 31001] New: Slow code generated for memcpy of a `zext i1`
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Nov 12 15:37:13 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=31001
Bug ID: 31001
Summary: Slow code generated for memcpy of a `zext i1`
Product: libraries
Version: 3.9
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: arielb1 at mail.tau.ac.il
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
A memcpy with a constant length is lowered to a (fast) sequence of load and
store instructions. A memcpy with a non-constant length is lowered to a call to
the memcpy function, which is slow for short copies.
For example, a memcpy of a `zext i1` is equivalent to a conditional load and
store of a single byte, but the generated IR (and ASM) contains a call to
memcpy:
```
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture
readonly, i64, i32, i1) #2
define i8 @test_load_store(i1 %cond, i8* %buf) {
%_result = alloca i8, align 8
%_len = zext i1 %cond to i64
store i8 0, i8* %_result
call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull %_result, i8* nonnull %buf,
i64 %_len, i32 1, i1 false)
%_ret = load i8, i8* %_result
ret i8 %_ret
}
```
This causes slowness in Rust's Cursor::read, which we discovered in PR
https://github.com/rust-lang/rust/pull/37573..
--
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/20161112/212bed51/attachment-0001.html>
More information about the llvm-bugs
mailing list