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

    <tr>
        <th>Summary</th>
        <td>
            [RISCV] add new relocation type for gp
        </td>
    </tr>

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

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

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

<pre>
    Currently, the RISC-CV architecture addresses constant subscript elements of global arrays using `lui` + `ld/st`, and non-constant subscript elements using `lui` + `addi` + `add` + `ld/st`.
C code test like 
```
int ga[10]; 
int foo(int i) {
  return ga[i]
}
```
1) Without  GP relaxation
lui + addi + add/shxadd/shxadd + ld/st

<img width="1708" height="292" alt="Image" src="https://github.com/user-attachments/assets/94c4b0ed-9c60-46e6-a66d-0a2ef22aeed4" />

2) With GP relaxation
addi + add + ld/st

<img width="1780" height="260" alt="Image" src="https://github.com/user-attachments/assets/44f2939c-8477-4f67-867f-e3f14a176f5d" />

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VEHPnDYQ_TXDZcTKDMbAgQO7260i9VC1UnI2eAC3XtjaJsn37yuz36emSRv1UskS42fNm_dmNOgQ7Lwyd1Cdobpmeo_L5ruf7B92_cDrnA2beekuu_e8RvcCdMG4MP7y7tdLfnmP2o-LjTzG3TNqYzyHwAHHbQ1RrxHDPoTR20dEdnznNQbcJpzdNmiH2nv9EnAPdp0RlHC7BSUQ6HzcDNAtRFAiFdWrwXVb8-8x_wuRNuar6z9WOYHoLzhuhjFyiOjs74wg-iTgeURv14izhupcCKiuUJ7xFZy2DahJkQVqEeoziB7Rc9z9-kyxKUP0UF-_Ii1Sxgcbl22PiD_-jJ6d_qyj3VYQvdvtoTW5eAuS5OXzl8Hx8uZF9OmUF3uf8ZM1cYHyCkRFLRogwoXtvMQnRi0lSLvX-7u7njkhwY9PZInxEaDsgW5At9nGZR9O43YHuu2Bfa5j1ONyDADopkPgI2jlKAfBJm9HJXKpWOVaKZMLTTwRaWYjU51EW_7wlExvjfimCV-a_29WG_GNVSX-H6tSTtSW7Zg3sq5zOak6b1Q95VxOhdRFrabK_M1qZrrStGWrM-6Kui4LklUhs6VTRGXdiLEtSjVoEuUgWOpKToWshBFVZjsSpERZCKHKqpAn1oXQwrSDFkY1E4MUfNfWnZz7eD9tfs5sCDt3RVNVjcqcHtiFY9eJVv6ExysQpdX3XUrKh30OIIWzIYa_aKKN7vhJpM1_D9X1GEWi8Oy28RgUxpcH47R5nB_Z7l33nYYm4tdP_vDbbzxGoNshJ_X0Ve_Hjv4MAAD__yTcYmQ">