diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-03-21 14:07:18 +0000 |
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-03-21 14:07:18 +0000 |
| commit | da4992bf8ddb1586268c1aea8dbc6caa81b95030 (patch) | |
| tree | 1b65343e65fb3ec81532cb6d27dc7ccf98bb5eb4 /llvm/lib/CodeGen/SelectionDAG | |
| parent | d3511a214e47a54d840f4c0efe80ea94f60f5f25 (diff) | |
| download | bcm5719-llvm-da4992bf8ddb1586268c1aea8dbc6caa81b95030.tar.gz bcm5719-llvm-da4992bf8ddb1586268c1aea8dbc6caa81b95030.zip | |
[DAGCombine] SimplifySelectCC - call FoldSetCC with the setcc result type
We were calling FoldSetCC with the compare operand type instead of the result type.
Found by OSS-Fuzz #13838 (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13838)
llvm-svn: 356667
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 5862936a9e8..093da6f6e40 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -18948,13 +18948,14 @@ SDValue DAGCombiner::SimplifySelectCC(const SDLoc &DL, SDValue N0, SDValue N1, if (N2 == N3) return N2; EVT CmpOpVT = N0.getValueType(); + EVT CmpResVT = getSetCCResultType(CmpOpVT); EVT VT = N2.getValueType(); auto *N1C = dyn_cast<ConstantSDNode>(N1.getNode()); auto *N2C = dyn_cast<ConstantSDNode>(N2.getNode()); auto *N3C = dyn_cast<ConstantSDNode>(N3.getNode()); // Determine if the condition we're dealing with is constant. - if (SDValue SCC = DAG.FoldSetCC(VT, N0, N1, CC, DL)) { + if (SDValue SCC = DAG.FoldSetCC(CmpResVT, N0, N1, CC, DL)) { AddToWorklist(SCC.getNode()); if (auto *SCCC = dyn_cast<ConstantSDNode>(SCC)) { // fold select_cc true, x, y -> x @@ -19021,7 +19022,7 @@ SDValue DAGCombiner::SimplifySelectCC(const SDLoc &DL, SDValue N0, SDValue N1, SDValue Temp, SCC; // zext (setcc n0, n1) if (LegalTypes) { - SCC = DAG.getSetCC(DL, getSetCCResultType(CmpOpVT), N0, N1, CC); + SCC = DAG.getSetCC(DL, CmpResVT, N0, N1, CC); if (VT.bitsLT(SCC.getValueType())) Temp = DAG.getZeroExtendInReg(SCC, SDLoc(N2), VT); else |

