[llvm] [SystemZ] XPLINK64: emit narrow sign/zero-extend instructions for sub-i32 formal args (PR #206833)

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 06:37:09 PDT 2026


================
@@ -0,0 +1,251 @@
+; Test that sub-64-bit integer formal arguments and small struct formal
+; arguments are correctly sign/zero-extended by the callee in the z/OS
+; XPLINK64 calling convention.
+;
+; The XPLINK64 ABI does not require the caller to have extended the upper bits
+; of a GPR for named (non-variadic) integer arguments.  The callee therefore
+; must perform its own extension when it needs the full 64-bit value.
+;
+; Integer formals (CCIfExtend -> CCPromoteToType<i64> with isFormalArgLowering=true):
+;   For i8/i16 formals, CCPromoteToType<i64> keeps LocVT=i32 (GR32 live-in).
+;   LowerFormalArguments truncates the GR32 to the true i8/i16 type, so the
+;   subsequent sign/zero-extend to i64 selects the narrow register-extend
+;   instructions (LGBR/LGHR/LLGCR/LLGHR) matching XL compiler output.
+;   For i32 formals, LocVT=i64 (GR64), so LGFR is used as before.
----------------
uweigand wrote:

Some of those details no longer match the implementation.  In any case, they're not really required either - as long as we say we do not rely on the incoming argument already having been extended, and therefore we perform the extension in the callee.  It's not really necessary to re-iterate which instruction can be used to do the extension - that's mostly obvious, but also, no particular instruction is *required* as long as the extension is performed one way or the other.

(We don't want to have a comment here imply that certain things are required that actually are not.  That can only cause confusion in the future if anything changes.)

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


More information about the llvm-commits mailing list