[flang-commits] [flang] [llvm] [flang-rt] - Lightweight runtime assignment function (AssignSimple) for intrinsic-type assignments (PR #213704)

Pranav Bhandarkar via flang-commits flang-commits at lists.llvm.org
Wed Aug 5 14:48:52 PDT 2026


================
@@ -851,6 +852,218 @@ void RTDEF(AssignExplicitLengthCharacter)(Descriptor &to,
           ExplicitLengthCharacterLHS);
 }
 
+void RTDEF(AssignSimple)(Descriptor &to, const Descriptor &from,
+    const char *sourceFile, int sourceLine) {
+  Terminator terminator{sourceFile, sourceLine};
+  // AssignSimple: fast path for intrinsic type assignments (integer, real,
+  // complex, logical). The compiler routes here only when:
+  //   - LHS element type is trivial (isa_trivial), not derived/polymorphic
+  //   - LHS and RHS ranks match (no scalar-to-array broadcasting)
+  //   - LHS is not volatile (volatile needs memory ordering semantics)
+
+  if (to.rank() != from.rank()) {
+    terminator.Crash("AssignSimple: rank mismatch (to.rank=%d, from.rank=%d)",
+        to.rank(), from.rank());
+  }
+  if (to.ElementBytes() != from.ElementBytes()) {
----------------
bhandarkar-pranav wrote:

It should. good catch! thank you. My goal was to keep this consistent with `_FortranAAssign` for intrinsic types. I missed the type code check. 
Also, I am sorry that the PR description might give the impression that the goal is to minimise basic blocks. But, I feel that's too restrictive. My experience has been that avoiding the workqueue infrastructure is really what gets us all improvement. It reduces code bloat (i..e  instructions and basic blocks) dramatically. Adding a basic block or two here for checks at runtime isn't really a problem as long as we can stay clear of the workqueue infrastructure.

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


More information about the flang-commits mailing list