[llvm] [InstCombine] Combine trunc (lshr X, BW-1) to i1 --> icmp slt X, 0 (#142593) (PR #143846)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 12 02:04:30 PDT 2025


================
@@ -823,6 +823,14 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
       Value *And = Builder.CreateAnd(X, MaskC);
       return new ICmpInst(ICmpInst::ICMP_NE, And, Zero);
     }
+
+    if (match(Src, m_AShr(m_Value(X), m_SpecificInt(SrcWidth - 1))) ||
+        match(Src, m_LShr(m_Value(X), m_SpecificInt(SrcWidth - 1)))) {
----------------
mayanksolanki393 wrote:

yes, will fix

https://github.com/llvm/llvm-project/pull/143846


More information about the llvm-commits mailing list