Skip to content

Commit af4c4f4

Browse files
author
Cameron McInally
committed
[DAGCombine] Fix an ICE in combineMinNumMaxNum(...)
65420c8 introduced an ICE in combineMinNumMaxNum(...) when combineMinNumMaxNumImpl(...) returns an SDValue(). Make sure to check that a value is returned before trying to perform an FNEG on it. GitHub Issue: llvm#60924 Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D144571
1 parent a644666 commit af4c4f4

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10815,7 +10815,8 @@ SDValue DAGCombiner::combineMinNumMaxNum(const SDLoc &DL, EVT VT, SDValue LHS,
1081510815
if (NegRHS == False) {
1081610816
SDValue Combined = combineMinNumMaxNumImpl(DL, VT, LHS, RHS, NegTrue,
1081710817
False, CC, TLI, DAG);
10818-
return DAG.getNode(ISD::FNEG, DL, VT, Combined);
10818+
if (Combined)
10819+
return DAG.getNode(ISD::FNEG, DL, VT, Combined);
1081910820
}
1082010821
}
1082110822
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=skylake
2+
3+
; Checking for a DAGCombine ICE.
4+
5+
define float @test_combinemaxnum(float %sub) #0 {
6+
L.entry:
7+
%maxnum1 = call float @llvm.maxnum.f32(float 0.000000e+00, float 0.000000e+00)
8+
br label %L.LB21_850
9+
10+
L.LB21_850:
11+
%neg1 = fneg fast float %maxnum1
12+
%neg2 = fneg fast float %sub
13+
%mask = fcmp fast ule float %maxnum1, %neg2
14+
%maxnum2 = select i1 %mask, float %neg1, float %sub
15+
ret float %maxnum2
16+
}
17+
18+
declare float @llvm.maxnum.f32(float, float)
19+
20+
attributes #0 = { "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" }

0 commit comments

Comments
 (0)