diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2024-04-19 11:37:37 +0100 |
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2024-04-19 13:47:29 +0100 |
| commit | 2e68ba99def5b07f4c6c53627baf076c5c924979 (patch) | |
| tree | 9db45a4f4748b75c418d7af3faea19ee176ecb66 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
| parent | 7fbdadb68e259079d23165ecb94e2893a3823576 (diff) | |
| download | llvm-2e68ba99def5b07f4c6c53627baf076c5c924979.tar.gz llvm-2e68ba99def5b07f4c6c53627baf076c5c924979.tar.bz2 llvm-2e68ba99def5b07f4c6c53627baf076c5c924979.zip | |
[DAG] visitADDLike - update "(x - y) + -1 -> add (xor y, -1), x" fold to accept UNDEF in a splat vector of -1
Make sure we use getNOT instead of reusing the allones (with undefs) vector
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 0ea0c0df7f37..a21b9acad7da 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -2831,9 +2831,9 @@ SDValue DAGCombiner::visitADDLike(SDNode *N) { // (x - y) + -1 -> add (xor y, -1), x if (N0.getOpcode() == ISD::SUB && N0.hasOneUse() && - isAllOnesOrAllOnesSplat(N1)) { - SDValue Xor = DAG.getNode(ISD::XOR, DL, VT, N0.getOperand(1), N1); - return DAG.getNode(ISD::ADD, DL, VT, Xor, N0.getOperand(0)); + isAllOnesOrAllOnesSplat(N1, /*AllowUndefs=*/true)) { + SDValue Not = DAG.getNOT(DL, N0.getOperand(1), VT); + return DAG.getNode(ISD::ADD, DL, VT, Not, N0.getOperand(0)); } if (SDValue Combined = visitADDLikeCommutative(N0, N1, N)) |
