[llvm] [llvm][GVN] Propagate `trunc nuw to i1` equalities (PR #143273)

Yash Solanki via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 7 15:59:59 PDT 2025


================
@@ -2579,6 +2579,22 @@ bool GVNPass::propagateEquality(Value *LHS, Value *RHS,
 
       continue;
     }
+
+    // Propagate equality that result from truncation with no unsigned wrap
+    // like (trunc nuw i64 %v to i1) == "true" or (trunc nuw i64 %v to i1) ==
+    // "false"
+    if (auto *Trunc = dyn_cast<TruncInst>(LHS)) {
----------------
yashnator wrote:

I have not yet removed the braces because the documentation suggests using braces to avoid dangling else statements. Let me know if I need to remove them

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


More information about the llvm-commits mailing list