[llvm] [X86] Improve illegal return type handling in FastISel (PR #186723)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 16 01:32:23 PDT 2026
================
@@ -3200,11 +3200,25 @@ bool X86FastISel::fastLowerCall(CallLoweringInfo &CLI) {
bool Is64Bit = Subtarget->is64Bit();
bool IsWin64 = Subtarget->isCallingConvWin64(CC);
- // If the return type is illegal, don't bother to promote it, just fall back
- // to DAG ISel.
+ // If the return type is illegal, check if the ABI requires a type conversion
+ // that FastISel cannot handle. Fall back to DAG ISel in such cases.
+ // For example, bfloat is returned as f16 in XMM0, however FastISel would
+ // assign f32 register type and store it in FuncInfo.ValueMap. This would
+ // cause DAG incorrectly perform type conversion from f32 to bfloat after get
+ // the value from FuncInfo.ValueMap.
+ // However, i1 is promoted to i8 and return i8 defined by ABI, so FastISel can
+ // lower it without switching to DAGISel.
MVT RetVT;
- if (!isTypeLegal(CLI.RetTy, RetVT) && !CLI.RetTy->isVoidTy())
- return false;
+ if (!isTypeLegal(CLI.RetTy, RetVT) && !CLI.RetTy->isVoidTy()) {
+ EVT RetEVT = EVT::getEVT(CLI.RetTy, /*HandleUnknown=*/true);
----------------
phoebewang wrote:
Can we use `RetVT` here?
https://github.com/llvm/llvm-project/pull/186723
More information about the llvm-commits
mailing list