[clang] [MSVC, ARM64] Add _Copy* and _Count* intrinsics (PR #66554)

Amy Huang via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 18 15:50:35 PDT 2023


================
@@ -10752,6 +10752,68 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
     return Load;
   }
 
+  if (BuiltinID == AArch64::BI_CopyDoubleFromInt64 ||
+      BuiltinID == AArch64::BI_CopyFloatFromInt32 ||
+      BuiltinID == AArch64::BI_CopyInt32FromFloat ||
+      BuiltinID == AArch64::BI_CopyInt64FromDouble) {
+    return EmitScalarExpr(E->getArg(0));
----------------
amykhuang wrote:

Oh, ok -- added a int to float cast. It seems like MSVC only emits an `fmov` for this code, so for an example snippet

```
double copy_double_from_int64(__int64 w) {
  return _CopyDoubleFromInt64((__int64) w);
}
```

MSVC assembly output looks like

```
        sub       sp,sp,#0x10
        str         x0,[sp]
        ldr         x8,[sp]
        fmov     d0,x8
        add       sp,sp,#0x10
        ret
```

whereas clang assembly output (with the cast) looks like 

```
        sub     sp, sp, #16
        str       x0, [sp, #8]
        ldr      d0, [sp, #8]
        scvtf   d0, d0
        add    sp, sp, #16
        ret
```

https://github.com/llvm/llvm-project/pull/66554


More information about the cfe-commits mailing list