Skip to content

Commit 5b6b4fd

Browse files
authored
DAG: Fix promote of half freeze (#131844)
1 parent 945ce96 commit 5b6b4fd

File tree

3 files changed

+9811
-1
lines changed

3 files changed

+9811
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2763,7 +2763,12 @@ void DAGTypeLegalizer::PromoteFloatResult(SDNode *N, unsigned ResNo) {
27632763
#endif
27642764
report_fatal_error("Do not know how to promote this operator's result!");
27652765

2766-
case ISD::BITCAST: R = PromoteFloatRes_BITCAST(N); break;
2766+
case ISD::BITCAST:
2767+
R = PromoteFloatRes_BITCAST(N);
2768+
break;
2769+
case ISD::FREEZE:
2770+
R = PromoteFloatRes_FREEZE(N);
2771+
break;
27672772
case ISD::ConstantFP: R = PromoteFloatRes_ConstantFP(N); break;
27682773
case ISD::EXTRACT_VECTOR_ELT:
27692774
R = PromoteFloatRes_EXTRACT_VECTOR_ELT(N); break;
@@ -2876,6 +2881,18 @@ SDValue DAGTypeLegalizer::PromoteFloatRes_BITCAST(SDNode *N) {
28762881
return DAG.getNode(GetPromotionOpcode(VT, NVT), SDLoc(N), NVT, Cast);
28772882
}
28782883

2884+
SDValue DAGTypeLegalizer::PromoteFloatRes_FREEZE(SDNode *N) {
2885+
EVT VT = N->getValueType(0);
2886+
EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
2887+
// Input type isn't guaranteed to be a scalar int so bitcast if not. The
2888+
// bitcast will be legalized further if necessary.
2889+
EVT IVT = EVT::getIntegerVT(*DAG.getContext(),
2890+
N->getOperand(0).getValueType().getSizeInBits());
2891+
SDValue Cast = DAG.getBitcast(IVT, N->getOperand(0));
2892+
return DAG.getNode(GetPromotionOpcode(VT, NVT), SDLoc(N), NVT,
2893+
DAG.getFreeze(Cast));
2894+
}
2895+
28792896
SDValue DAGTypeLegalizer::PromoteFloatRes_ConstantFP(SDNode *N) {
28802897
ConstantFPSDNode *CFPNode = cast<ConstantFPSDNode>(N);
28812898
EVT VT = N->getValueType(0);

llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
756756

757757
void PromoteFloatResult(SDNode *N, unsigned ResNo);
758758
SDValue PromoteFloatRes_BITCAST(SDNode *N);
759+
SDValue PromoteFloatRes_FREEZE(SDNode *N);
759760
SDValue PromoteFloatRes_BinOp(SDNode *N);
760761
SDValue PromoteFloatRes_UnaryWithTwoFPResults(SDNode *N);
761762
SDValue PromoteFloatRes_ConstantFP(SDNode *N);

0 commit comments

Comments
 (0)