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

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 (

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 ( 

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.
llvm-bugs mailing list

Reply via email to