<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/143191>143191</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [HLSL] static constants are not fully optimized
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            HLSL,
            backend:SPIR-V
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          s-perron
      </td>
    </tr>
</table>

<pre>
    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;
}
```


</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxck09vpDgQxT9NcSk1sk0DzYFD_9lWVsphlUS7ZwMFeMfYPXbRmeTTj6B7JplIRhyo93t-pYeO0QyOqIb8APkp0TOPPtRxc6EQvEsa373VLyMh_dDTxRI2ZP0rvhprcSBHQTOhxlZbi-xROzSOg3HRtAiFgK2w9jqlxl11MNpxGlkHTi8CCoGG0bjOtAuDR83II-E62Fi6eTjP2I7aDYS6ZwqrJqJxho225p26FB_8K10pgDoijyZiJJricpvRuI4C-gubybxrNt7FFJc0kX2gZeQPx0XLi-slUCTHd8sv-mciHJkvEbI9qDOo8-C7xltOfRhAnd9BnfuXrPrudR9SEPvlFOJ-xP7pv8Pc9xQgOxrHkP2FDUK2x0CDibzk2M0CVAXZ4SY2jrH3HtQOVIVQHjAQz8GhEpAdEMrTbS6yZtNi611cFsvYImSnD-lvIOQHN088BtJdBLWToI73p4J8oV296XDSxn2YgtgjIjaQHwTkpxXd3pG3G3zKCGKfdHXWVVmlE6plua1UlhdSJmO9LSXtdiLbUpuVuu9lX1DZSSn7XKltKxNTK6FyUYhC7rZFLtNOtaJsZF5JLaUul1bRpI1N1275MCQmxplquc1kJROrG7JxbbRSD4_Pj6AUqCMo1ej2G7kOsv3zP38_bf5dPuSnJNQLaNPMQ1wKayLHDzQbtuvvsZLyE35es3YcUQdae9rP1r79agt1yRxs_aUohse5SVs_gTovDvfX5hL8_9QyqPOaJII638Nca_UzAAD__43LIwA">