[llvm] [AArch64][InstCombine] xor(cmpne) -> cmpeq (PR #207007)
Matthew Devereau via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 2 08:40:16 PDT 2026
================
@@ -2142,10 +2142,43 @@ static std::optional<Instruction *> instCombineSVEDupX(InstCombiner &IC,
return IC.replaceInstUsesWith(II, Splat);
}
+static std::optional<Instruction *> instCombineXorSVECmpNE(InstCombiner &IC,
+ IntrinsicInst &II) {
+ if (!match(II.getOperand(2), m_Zero()) || !II.hasOneUse())
+ return std::nullopt;
+
+ auto *User = cast<Instruction>(*II.user_begin());
+ if (!match(User, m_c_Xor(m_Specific(&II), m_Specific(II.getOperand(0)))))
+ return std::nullopt;
+
+ Intrinsic::ID IID;
+ switch ((II.getIntrinsicID())) {
+ case Intrinsic::aarch64_sve_cmpne:
+ IID = Intrinsic::aarch64_sve_cmpeq;
+ break;
+ case Intrinsic::aarch64_sve_cmpne_wide:
+ IID = Intrinsic::aarch64_sve_cmpeq_wide;
----------------
MDevereau wrote:
I think so, though the only other similar case I've seen used in the real world is this, where a cmpne(ptrue)+zext from i1 can be reduced to just an immediate umin:
https://godbolt.org/z/Ms4vYa7Yn.
After this I was planning to give that a go and then look if fcmp could benefit from the same combines or if floating point flags complicated things too much. Without these combines SVE vl256 falls short of Neon in these functions.
https://github.com/llvm/llvm-project/pull/207007
More information about the llvm-commits
mailing list