[llvm] [SystemZ] XPLINK64: emit narrow sign/zero-extend instructions for sub-i32 formal args (PR #206833)
Zibi Sarbinowski via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 1 07:00:05 PDT 2026
================
@@ -2152,8 +2153,23 @@ SDValue SystemZTargetLowering::LowerFormalArguments(
assert(PartOffset && "Offset should be non-zero.");
}
}
- } else
- InVals.push_back(convertLocVTToValVT(DAG, DL, VA, Chain, ArgValue));
+ } else {
+ SDValue Val = convertLocVTToValVT(DAG, DL, VA, Chain, ArgValue);
----------------
zibi2 wrote:
We tried extending the condition to cover i32 (using OrigVT < LocVT instead of OrigVT < ValVT), which would bypass convertLocVTToValVT for i32 signext formals too. It breaks call-zos-01.ll and call-zos-vararg.ll: without convertLocVTToValVT emitting AssertSext i64→i32, the optimizer sees a plain TRUNCATE i64→i32 and — since the subsequent use sign-extends back to i64 — folds the truncate+extend away to a no-op, emitting lgr instead of lgfr. That is incorrect under XPLINK64 because the ABI does not guarantee the caller sign-extended the i32, so the callee must do it explicitly. The AExt in CC_XPLINK_Promote_i32 suppresses AssertSext for i32 formals, keeping the optimizer conservative and preserving lgfr.
https://github.com/llvm/llvm-project/pull/206833
More information about the llvm-commits
mailing list