[llvm] [VPlan] Remove (X && Y) | (X && !Y) -> X combine. NFC (PR #219368)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 03:10:06 PDT 2026


================
@@ -1171,13 +1171,7 @@ static void removeRedundantExpandSCEVRecipes(VPlan &Plan) {
 
 /// Try to simplify logical and bitwise recipes in \p Def.
 static VPValue *simplifyLogicalRecipe(VPlan &Plan, VPSingleDefRecipe *Def) {
-  // Simplify (X && Y) | (X && !Y) -> X.
-  // TODO: Remove now that we have smaller combines for this.
-  VPValue *X, *Y;
----------------
fhahn wrote:

It looks like there may be a regression with multiple uses, e.g. something like that now misses the fold I think:


```
define void @g(ptr noalias %c, ptr noalias %d, ptr noalias %p, ptr noalias %q, ptr noalias %r, i64 %n) {
entry:
  br label %loop

loop:
  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
  %cp = getelementptr inbounds i8, ptr %c, i64 %iv
  %cv = load i8, ptr %cp
  %x = icmp ne i8 %cv, 0
  %dp = getelementptr inbounds i8, ptr %d, i64 %iv
  %dv = load i8, ptr %dp
  %y = icmp ne i8 %dv, 0
  %ny = xor i1 %y, true
  %a1 = select i1 %x, i1 %y, i1 false
  %a2 = select i1 %x, i1 %ny, i1 false
  %o = or i1 %a1, %a2
  %qp = getelementptr inbounds i1, ptr %q, i64 %iv
  store i1 %a1, ptr %qp
  %rp = getelementptr inbounds i1, ptr %r, i64 %iv
  store i1 %a2, ptr %rp
  %pp = getelementptr inbounds i1, ptr %p, i64 %iv
  store i1 %o, ptr %pp
  %iv.next = add nuw nsw i64 %iv, 1
  %ec = icmp eq i64 %iv.next, %n
  br i1 %ec, label %exit, label %loop

exit:
  ret void
}
```

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


More information about the llvm-commits mailing list