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

    <tr>
        <th>Summary</th>
        <td>
            [RISCV] fpic optimisation 
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          abukharmeh
      </td>
    </tr>
</table>

<pre>
    When compiling position independent code for RISC-V and trying to access global variable inside loops, the compiler tries to get the address of global variable from GOT in every iteration of the loop, while in ARM, it does it only once before entering the loop.

https://godbolt.org/z/YMoxGrY97
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxlUE9vnTAM_zRwsYoggffKgcNbq1Y9VJO6qVOPAQx4DRgl4XVvn34O7VRpkxInlu3fH7fcX5ofEy7Q8bySpWWElT0F4gVo6XFFCUuQco8wsIOnh283V89glh6Cu8T-wGC6Dr2H0XJrLJyNI9NaFABPMmaZV5-oGwgTfvCgk2lCH4dHDHvF9L2LKDz8BzQ4nuH-63dBBDyjuwAFdGZXKe1xOpJEjreJdmY4PT3GnAL0LETy8mIvEjqEFsUKghhDt1v4AMiS_DbJT-9xCkFk61Oi7uSM3LdsQ8ZulOy33JdH_nXvXupj2je6r3Vt0kDBYpNUX-KWnpPqFoaVOuA10Ez-XW-6Odv8g01h2tpMViOJtee_z9Xq-Cd2QVLyfkNZ4l1V6qNKp8aUR1UVujDqWBfVUGFdHPQBhxLLrr4eDqk1LVofxSRKLfgGO4T8RVZKjcqVynVRFlorrbMS1XVZlVWBxlRDrpIyx9mQzaKOaDp1zS6p3UYvRUs--M-i8Z7GBXfvEd9sYWLXmHZ7nYybcUp39mZX_wePCdF6">