[llvm-bugs] [Bug 41137] New: missed opt: target-feature propagation
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Mar 19 05:42:17 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41137
Bug ID: 41137
Summary: missed opt: target-feature propagation
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: gonzalobg88 at gmail.com
CC: llvm-bugs at lists.llvm.org
Minimal working example - this Rust code:
extern "C" {
#[target_feature(enable = "avx2")]
pub fn foo();
}
pub unsafe fn bar() { foo() }
generated the following LLVM-IR (https://rust.godbolt.org/z/fzcraS):
define void @bar() unnamed_addr #0 {
tail call void @foo()
ret void
}
declare void @foo() unnamed_addr #1
attributes #0 = { nounwind nonlazybind uwtable
"probe-stack"="__rust_probestack" "target-cpu"="x86-64" }
attributes #1 = { nounwind nonlazybind uwtable
"probe-stack"="__rust_probestack" "target-cpu"="x86-64"
"target-features"="+avx2" }
which `opt` does not optimize further (https://rust.godbolt.org/z/XgMyCJ).
Note that `foo` does get the "target-features"="+avx2" attribute added, which
in general can significantly impact code generation.
This optimization is sound, because if `foo` is called on a platform without
`avx2` support, the behavior is undefined. That is, LLVM can always assume that
`foo` will only be called on platforms where `avx2` is enabled.
--
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/20190319/75b27508/attachment.html>
More information about the llvm-bugs
mailing list