[llvm] [LLVM][DAGCombiner][SVE] Fold vselect into merge_pasthru_op. (PR #146917)
Kerry McLaughlin via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 3 10:04:51 PDT 2025
================
@@ -25531,6 +25534,22 @@ static SDValue performVSelectCombine(SDNode *N, SelectionDAG &DAG) {
if (isAllInactivePredicate(N0))
return N->getOperand(2);
+ if (isMergePassthruOpcode(IfTrue.getOpcode()) && IfTrue.hasOneUse()) {
+ // vselect A, (merge_pasthru_op all_active, B,{Bn,} -), C
+ // vselect A, (merge_pasthru_op -, B,{Bn,} undef), C
+ // vselect A, (merge_pasthru_op A, B,{Bn,} -), C
+ // -> merge_pasthru_op A, B,{Bn,} C
+ if (isAllActivePredicate(DAG, IfTrue->getOperand(0)) ||
+ IfTrue->getOperand(IfTrue.getNumOperands() - 1).isUndef() ||
+ IfTrue->getOperand(0) == N0) {
----------------
kmclaughlin-arm wrote:
Are there any tests where `isAllActivePredicate(DAG, IfTrue->getOperand(0))` is not true? From what I can tell, all of the affected tests in sve-merging-unary.ll were using `ptrue` before this change & still pass if I try removing the other conditions.
https://github.com/llvm/llvm-project/pull/146917
More information about the llvm-commits
mailing list