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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 12 03:24:02 PDT 2025


================
@@ -815,6 +815,13 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
       return new ICmpInst(ICmpInst::ICMP_EQ, X, CmpC);
     }
 
+    if (match(Src, m_AShr(m_Value(X), m_SpecificInt(SrcWidth - 1))) ||
+        match(Src, m_LShr(m_Value(X), m_SpecificInt(SrcWidth - 1)))) {
----------------
nikic wrote:

```suggestion
    if (match(Src, m_Shr(m_Value(X), m_SpecificInt(SrcWidth - 1)))) {
```

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


More information about the llvm-commits mailing list