Issue 240939
Summary Post-RA scheduler undoes the optimized pre-RA schedule
Labels backend:RISC-V, mi-sched
Assignees
Reporter pgodeq
    The pre-RA schedule at https://godbolt.org/z/sfcxTnY1d , correctly inserts independent instructions between load and it's use, given that the load latency of RISC-V generic CPU is 4 (as per debug logs from machine scheduler).

```
        xor     a0, a0, s2
        zext.b  a0, a0
 sh2add  a0, a0, s3
   -> lw      a0, 0(a0)   // load
        srli    a1, s2, 8
   -> xor     s2, a0, a1  // use
        addi    s1, s1, -1
 sw      s2, 0(s0)
```

However, the post-RA hoists these instructions before load, which incurs performance penalty as load and it's use are scheduled consecutively. https://godbolt.org/z/jT38hfnoz

 ```
       xor a0, a0, s2
        srli    a1, s2, 8   // hoisted here. 
        zext.b a0, a0
        addi    s1, s1, -1
        sh2add  a0, a0, s3
   -> lw a0, 0(a0)   // load
   -> xor     s2, a0, a1  // use
        sw      s2, 0(s0)

```
Could someone please help and share if this can be corrected or I am missing something ?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to