[llvm] [InstCombine] Added optimisation for trunc (Pow2 >> x) to i1 (PR #157030)
Andreas Jonson via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 7 14:23:22 PDT 2025
================
@@ -969,6 +971,25 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
Changed = true;
}
+ const APInt *C1;
+ Value *V1;
+ // trunc (lshr i8 C1, V1) to i1 -> icmp eq V1, log_2(C1) iff C1 is power of 2
+ if (DestWidth == 1 &&
+ match(Src, m_OneUse(m_Shr(m_Power2(C1), m_Value(V1))))) {
----------------
andjo403 wrote:
think that the m_OneUse can be removed as this only produce one instruction and this fold will reduce the number of uses for the shr instruction that can lead to more optimizations
https://github.com/llvm/llvm-project/pull/157030
More information about the llvm-commits
mailing list