[llvm] Combine (X ^ Y) and (X == Y) where appropriate (PR #130922)
Ryan Buchner via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 12 09:21:00 PDT 2025
================
@@ -8578,7 +8578,8 @@ static bool optimizeBranch(BranchInst *Branch, const TargetLowering &TLI,
}
if (Cmp->isEquality() &&
(match(UI, m_Add(m_Specific(X), m_SpecificInt(-CmpC))) ||
- match(UI, m_Sub(m_Specific(X), m_SpecificInt(CmpC))))) {
+ match(UI, m_Sub(m_Specific(X), m_SpecificInt(CmpC))) ||
+ match(UI, m_Xor(m_Specific(X), m_SpecificInt(CmpC))))) {
----------------
bababuck wrote:
Yes. There were two changes needed, first making sure the CodeGen shifts the `Xor` before the comparison (this change), and second imaking sure the RISCV backend doesn't fold the `xor` back in with the comparison.
https://github.com/llvm/llvm-project/pull/130922
More information about the llvm-commits
mailing list