[clang] [llvm] [InstCombine] Infer nusw + nneg -> nuw for getelementptr (PR #111144)

via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 4 07:21:49 PDT 2024


================
@@ -3096,6 +3096,15 @@ Instruction *InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
     }
   }
 
+  // nusw + nneg -> nuw
+  if (GEP.hasNoUnsignedSignedWrap() && !GEP.hasNoUnsignedWrap() &&
+      all_of(GEP.indices(), [&](Value *Idx) {
+        return isKnownNonNegative(Idx, SQ.getWithInstruction(&GEP));
+      })) {
----------------
goldsteinn wrote:

Any alleviation of compile time impact if you do only constants first to rule out trivial case?

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


More information about the cfe-commits mailing list