[llvm] [ValueTracking] isNonZero trunc of sub of ptr2int's with recursive GEP where pointers are limited to a 32bit alloc. (PR #84933)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 24 18:22:39 PDT 2024


================
@@ -910,6 +916,67 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
     Changed = true;
   }
 
+  // Handle scenarios like trunc i64 (sub(ptr2int, ptr2int)) to i32 / trunc i64
----------------
nikic wrote:

Shouldn't this logic be inside computeKnownBits() for sub? The information we get out of this is that the top bits of the sub result are zero. That will result in the nuw flag on trunc being set down the line.

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


More information about the llvm-commits mailing list