Skip to content

[HLSL] static constants are not fully optimized #143191

Open
@s-perron

Description

@s-perron

The example below will generate a call to an intrinsic @llvm.invariant.start.p0 it indicate that the variable will not change after it is initialized. However, this seems to hinder optimizations. The store to the variable is still present after optimizations. See https://godbolt.org/z/fT39qoafr.

RWBuffer<int> b : register(u0);

int foo() { return 20; }

static const int c = foo();

[numthreads(1,1,1)]
void main() {
    b[0] = c;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    HLSLHLSL Language Support

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions