| Issue |
172326
|
| Summary |
LLVM memcpy/set optimizations prevented by uninitialized padding
|
| Labels |
missed-optimization,
llvm:ir
|
| Assignees |
|
| Reporter |
MacDue
|
Reduced from a C++ class initialization. It should be possible to rewrite:
```llvm
define void @src(ptr %a) {
%alloca = alloca <{ [2 x i8], i64, i64, i64 }>, align 2
%3 = getelementptr inbounds nuw i8, ptr %alloca, i64 2
call void @llvm.memset.p0.i64(ptr noundef nonnull align 2 dereferenceable(24) %3, i8 0, i64 24, i1 false)
call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 2 dereferenceable(26) %a, ptr noundef nonnull align 2 dereferenceable(26) %alloca, i64 26, i1 false)
ret void
}
```
Into something like:
```llvm
define void @tgt(ptr %a) {
%3 = getelementptr inbounds nuw i8, ptr %a, i64 2
call void @llvm.memset.p0.i64(ptr noundef nonnull align 2 dereferenceable(24) %3, i8 0, i64 24, i1 false)
ret void
}
```
Which eliminates an alloca and a copy, but LLVM current fails to do so: https://godbolt.org/z/hKqnzs7v7
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs