[llvm] [ValueTracking] Handle assume( trunc x to i1) (PR #118406)

Andreas Jonson via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 00:13:18 PST 2024


================
@@ -612,11 +612,16 @@ static bool isKnownNonZeroFromAssume(const Value *V, const SimplifyQuery &Q) {
     // Warning: This loop can end up being somewhat performance sensitive.
     // We're running this loop for once for each value queried resulting in a
     // runtime of ~O(#assumes * #values).
+    Value *Arg = I->getArgOperand(0);
+    if (match(Arg, m_TruncOrSelf(m_Specific(V))) &&
+        isValidAssumeForContext(I, Q.CxtI, Q.DT)) {
----------------
andjo403 wrote:

I do not know if there is that many assumptions like this right now but was looking at folding some icmp eq X, C to trunc X to i1 when X is known to be 0 or 1 and got lots of regressions due to this.

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


More information about the llvm-commits mailing list