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

    <tr>
        <th>Summary</th>
        <td>
            [LoongArch] compile inline assembly using movgr2fcsr error
        </td>
    </tr>

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

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

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

<pre>
    Compile errer info:

```
clang --target=loongarch64-unknown-linux-gnu -c -S -nostdlib demo.c -o demo.S 
demo.c:6:2: error: invalid operand for instruction 
    6 |         "  movgr2fcsr %0, $r0" 
      |         ^ 
<inline asm>:1:16: note: instantiated into assembly here 
 1 |           movgr2fcsr $a1, $r0 
      | ^ 
1 error generated.
```

demo.c file
```c
int main(void) {
 int v = 0;
        __asm__ __volatile__(
        "  movgr2fcsr %0, $r0"
        : : "r"(v));
        return 0;
}
```
demo.ll file
```llvm
; ModuleID = 'demo.c' 
source_filename = "demo.c"
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
target triple = "loongarch64-unknown-linux-gnu"

; Function Attrs: noinline nounwind optnone
define dso_local signext i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  store i32 0, ptr %1, align 4
 store i32 0, ptr %2, align 4
  %3 = load i32, ptr %2, align 4
  call void asm sideeffect "  movgr2fcsr $0, $$r0", "r"(i32 %3) #1, !srcloc !5
  ret i32 0
}

attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-feature
s"="+64bit,+d,+f" }
attributes #1 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4} 
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"frame-pointer", i32 2}
!4 = !{!"clang version 16.0.0"}
!5 = !{i64 55}
```

The clang is built from main branch that downloaded yesterday. version info:
clang version 18.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/sam/opt/llvm-main-linux-ohos/bin

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVk2P4jgQ_TXmUgpK7CSEAwcaBmmkWWml2TsySSXxjmMj26G799ev7Dg00PRMC9IJro9Xr1455taKTiFuSPFCiv2Cj67XZmP5YLXqqjJLFyfdvG92ejgLiYDGoAGhWk3YlqR7ks7XMo2f8FhLrjpIEsdNh46wvdRaddzUfZkno_ql9KtKpFDjW9KpEZIakp-QKG1dI8UJGhz0soZET3c_YYo6_UzYtiRsSwnbejza-BuhLlyKBvQZDVcNtNrDtM6MtRNaxQAAACWQ1Q7mP0IpwKAvnaFtbQ0QWqSE7oDQ3KR-8cMR7h2Lb3GNsJ1QUigEbgfCvhG2zfzXgwSlHU74rOPKCe6wAaGcBm4tDif5Dj0anNNkdzkekOU8u0L7hOsDTzaxAh0qND7f8mmLbimFVkh8sKqnZ6EcDFwoQquLFg2hayCrl5jdL16AsD2khL3cQgI4Hrkdjkc4Hi9acickHo-EVvdGf6L_wZptpy-lxi_S6kLo2n8ekxt0o1E3qMhq_5SFUL-UzwiQ8jLMHX6Bv3QzSvy-D9USuopapKvIutWjqfHo4yg-YDSjs1msZJoHaLjjkr_r0c12mAyEbTE5e3Xn4ZKI601GK68oWiWqzJOf_vEhojPiLK9ZfzttV9eP4g6jmsZk65yxk26jppUe1atQfrKc0gpn2lq_2Fh9lLrmEsI28uZAMAokT6NiglooS28k41ucBZxcelfv4TvOpegU5DdW9M9W1mmDIWdQzdkFBWWfLZ8bfpGYhcRS82ZO-xv7mksJfjL89IMVDWLbYu2eSDufpX1Vd3ictRyoowWLpMVZz6yppa79XTHnNOhiLQ_aDlfunBGn0aGN3HtNrF6-bqnH0Bo-YHLWQjkMeNieUMqlDHsgpUonzvDzWaguGbj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