[llvm] [LLVM][InstCombine] Enable simplification of SVE predicate binops. (PR #211016)

Matthew Devereau via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 23 02:10:27 PDT 2026


================
@@ -1998,11 +2008,30 @@ simplifySVEIntrinsic(InstCombiner &IC, IntrinsicInst &II,
 // from_svbool is free.
 static std::optional<Instruction *>
 tryCombineFromSVBoolBinOp(InstCombiner &IC, IntrinsicInst &II) {
+  auto m_ConvertToSVBool = [](auto P) {
+    return m_Intrinsic<Intrinsic::aarch64_sve_convert_to_svbool>(P);
+  };
+  auto CreateConvertFromSVBool = [&IC](Type *Ty, Value *V) {
+    unsigned IID = Intrinsic::aarch64_sve_convert_from_svbool;
+    return IC.Builder.CreateIntrinsic(IID, Ty, V);
+  };
+
+  Type *Ty = II.getType();
+  Value *NarrowLHS, *RHS;
+
+  if (match(II.getOperand(0),
+            m_c_LogicalAnd(m_ConvertToSVBool(m_SpecificType(Ty, NarrowLHS)),
----------------
MDevereau wrote:

It looks like m_c_LogicalAnd also matches 
```
  %t1 = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv8i1(<vscale x 8 x i1> %a)
  %t2 = select <vscale x 16 x i1> %b, <vscale x 16 x i1> %t1, <vscale x 16 x i1> zeroinitializer
  %t3 = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %t2)
```
and this combines it into
```
%t1 = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %b)
%t2 = select <vscale x 8 x i1> %a, <vscale x 8 x i1> %t1, <vscale x 8 x i1> zeroinitializer
```
which I think incorrectly propagates poison when %a is poison and %b is false?

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


More information about the llvm-commits mailing list