[llvm] [X86] Align f128 and i128 to 16 bytes when passing on x86-32 (PR #138092)

Trevor Gross via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 11 05:27:52 PDT 2025


================
@@ -237,9 +237,18 @@ EVT X86TargetLowering::getSetCCResultType(const DataLayout &DL,
 bool X86TargetLowering::functionArgumentNeedsConsecutiveRegisters(
     Type *Ty, CallingConv::ID CallConv, bool isVarArg,
     const DataLayout &DL) const {
-  // i128 split into i64 needs to be allocated to two consecutive registers,
-  // or spilled to the stack as a whole.
-  return Ty->isIntegerTy(128);
+  // On x86-64 i128 is split into two i64s and needs to be allocated to two
+  // consecutive registers, or spilled to the stack as a whole. On x86-32 i128
+  // is split to four i32s and never actually passed in registers, but we use
+  // the consecutive register mark to match it in TableGen.
+  if (Ty->isIntegerTy(128))
+    return true;
+
+  // On x86-32, fp128 acts the same as i128.
+  if (Subtarget.is32Bit() && Ty->isFP128Ty())
+    return true;
+
+  return false;
----------------
tgross35 wrote:

I'm not sure if this is the right approach; `functionArgumentNeedsConsecutiveRegisters` doesn't really seem like the correct thing because the type will never be passed in regesters, but I can't come up with another way to "mark" a register set to indicate that it needs custom lowering. Is there a better way to do this?

Cc @nikic since I think you rewrote the x86-64 custom lowering a couple of times.

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


More information about the llvm-commits mailing list