[PATCH] D132206: [DAGCombiner] Fold vecreduce_xor/or/and(splat_vector(val)) to constant
WangLian via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 19 00:03:49 PDT 2022
Jimerlife created this revision.
Jimerlife added reviewers: RKSimon, sdesmalen, craig.topper, david-arm, benshi001.
Jimerlife added a project: LLVM.
Herald added subscribers: StephenFan, ecnelises, hiraditya.
Herald added a project: All.
Jimerlife requested review of this revision.
Herald added subscribers: llvm-commits, jacquesguan.
fold vecreduce_or/and(splat_vector(val)) -> constant val
fold vecreduce_xor(splat_vector(val)) -> constant zero
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D132206
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -23498,6 +23498,16 @@
return DAG.getNode(Opcode, SDLoc(N), N->getValueType(0), Subvec);
}
+ // fold vecreduce_or/and(splat_vector(val)) -> constant val
+ // fold vecreduce_xor(splat_vector(val)) -> constant zero
+ APInt SplatVal;
+ if (ISD::isConstantSplatVector(N0.getNode(), SplatVal)) {
+ if (Opcode == ISD::VECREDUCE_XOR)
+ return DAG.getConstant(0, SDLoc(N), N->getValueType(0));
+ if (Opcode == ISD::VECREDUCE_AND || Opcode == ISD::VECREDUCE_OR)
+ return DAG.getConstant(SplatVal, SDLoc(N), N->getValueType(0));
+ }
+
return SDValue();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132206.453900.patch
Type: text/x-patch
Size: 807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220819/bdcf327d/attachment.bin>
More information about the llvm-commits
mailing list