summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorgkoehler <gkoehler@openbsd.org>2020-05-02 05:34:08 +0000
committergkoehler <gkoehler@openbsd.org>2020-05-02 05:34:08 +0000
commitffca677e9e7ca9efd316fa2f2b6572b193c50cf8 (patch)
treecdf8f6f21165267a0e83d85a903c9f0a1ad21352 /gnu/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parentAdd const to TLS1.3 internal vectors (diff)
downloadwireguard-openbsd-ffca677e9e7ca9efd316fa2f2b6572b193c50cf8.tar.xz
wireguard-openbsd-ffca677e9e7ca9efd316fa2f2b6572b193c50cf8.zip
Don't make an illegal adde. Avoids fatal error on PowerPC.
When the DAG truncates an ISD::ADDE node, DAGCombiner may optimize it by making an adde with smaller operands. PowerPC has i1 registers, and may truncate an i32 adde to i1, but an i1 adde is not legal for PowerPC, and the legalize-ops phase can't fix it. This was causing "fatal error: error in backend: Cannot select..." cwen@ reported the error ok mortimer@ kettenis@ deraadt@
Diffstat (limited to 'gnu/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--gnu/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/gnu/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/gnu/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 6af01423ca1..8203476ed4e 100644
--- a/gnu/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/gnu/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -9904,9 +9904,11 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
// (trunc adde(X, Y, Carry)) -> (adde trunc(X), trunc(Y), Carry)
// (trunc addcarry(X, Y, Carry)) -> (addcarry trunc(X), trunc(Y), Carry)
// When the adde's carry is not used.
+ // Don't make an illegal adde: LegalizeDAG can't expand nor promote it.
if ((N0.getOpcode() == ISD::ADDE || N0.getOpcode() == ISD::ADDCARRY) &&
N0.hasOneUse() && !N0.getNode()->hasAnyUseOfValue(1) &&
- (!LegalOperations || TLI.isOperationLegal(N0.getOpcode(), VT))) {
+ ((!LegalOperations && N0.getOpcode() == ISD::ADDCARRY) ||
+ TLI.isOperationLegal(N0.getOpcode(), VT))) {
SDLoc SL(N);
auto X = DAG.getNode(ISD::TRUNCATE, SL, VT, N0.getOperand(0));
auto Y = DAG.getNode(ISD::TRUNCATE, SL, VT, N0.getOperand(1));