[llvm] [SelectionDAG] Fix load/store legalization for softened x86_fp80 (PR #209991)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 04:55:28 PDT 2026


================
@@ -1423,6 +1431,13 @@ SDValue DAGTypeLegalizer::SoftenFloatOp_STORE(SDNode *N, unsigned OpNo) {
   else
     Val = GetSoftenedFloat(Val);
 
+  // If softening widens the integer representation (e.g. x86_fp80 -> i96),
+  // truncate the value before storing to preserve the original memory width.
+  EVT MemVT =
+      EVT::getIntegerVT(*DAG.getContext(), ST->getMemoryVT().getSizeInBits());
+  if (Val.getValueType().bitsGT(MemVT))
+    return DAG.getTruncStore(ST->getChain(), dl, Val, ST->getBasePtr(), MemVT,
+                             ST->getMemOperand());
   return DAG.getStore(ST->getChain(), dl, Val, ST->getBasePtr(),
----------------
RKSimon wrote:

Just use a more general getStore call that handles implicit truncation?

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


More information about the llvm-commits mailing list