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

    <tr>
        <th>Summary</th>
        <td>
            [RISC-V] Use of %0 does not have a corresponding definition on every path with `-O0`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          patrick-rivos
      </td>
    </tr>
</table>

<pre>
    Reduced LLVM IR:
```
define i16 @f() {
BB:
  br label %BB1

BB1: ; preds = %BB1, %BB
  %A = or i16 0, 0
  %B = fcmp true float 0.000000e+00, 0.000000e+00
  %C = or i1 %B, false
  br i1 %C, label %BB1, label %BB2

BB2:                                              ; preds = %BB1
  ret i16 %A
}
```
Godbolt: https://godbolt.org/z/7GGzqs5c6

BB state before the LiveIntervalAnalysis pass from debug log:
```
BB.0    BB.3 (unreachable)
 |     /    \
BB.1(loops)  BB.2 -> ret
```

Since BB.1 defines %0 and BB.2 reads it, LiveIntervalAnalysis complains about
the undefined value in the unreachable codepath.

First visibly bad commit:
af82d01fbbce7808605f3a8b22dd1ca7fdec7886 [RISCV] Separate doLocalPostpass into new pass...

I think this is just because LiveIntervalAnalysis isn't run before this commit.

One step further back is the commit that causes bb to be split into bb.3.
2c185709bca195f3d5e062819bba5dd828330548 [RISCV] Remove setJumpIsExpensive()

Can be mitigated by -mllvm -jump-is-expensive=true
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVU1v4zgP_jXKhUggS_48-FAnk0Ff9MUsOti5SxYdq7UlryR7tvPrF7LTjyw6hzUKuzbJh3weUozwXl8MYk2yhmSnnZhDb109ieB0-7x3erF-J616qR9RzS0qeHj48X-4fyT8jtAToXckp9e_9VVhpw2CTnIgKe0IKwmrgBTNZm6at0AA6WAQEgcgLGua5Ip39UsIvwPCG5gcKg-En17d2HH77xWGsOxutVu35q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