[PATCH] D133362: [InstCombine] Fold x + (x | -x) to x & (x - 1)
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 6 09:36:51 PDT 2022
RKSimon added a comment.
Sorry for the short/blunt comments - running out of time today!
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1429
+ // (add A (or A (sub 0, A))) --> (and (add A, -1) A)
+ if (match(&I, m_c_BinOp(m_Or(m_Sub(m_ZeroInt(), m_Value(A)), m_Value(A)), m_Value(A)))) {
+ Value *AddInst = Builder.CreateAdd(A, Constant::getAllOnesValue(A->getType()));
----------------
Use m_Neg()? Also, you need to use m_Deferred() for those later m_Value()
================
Comment at: llvm/test/Transforms/InstCombine/add_or_sub.ll:26
+ ret i8 %add
+}
----------------
vector cases? multiuse cases? negative cases?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133362/new/
https://reviews.llvm.org/D133362
More information about the llvm-commits
mailing list