[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-09-04 Thread Hari Limaye via cfe-commits
hazzlim wrote: > Can this be closed in favor of #105496? Yes good point - will close this and open a PR to Reland #105496. https://github.com/llvm/llvm-project/pull/103088 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/

[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-09-04 Thread Hari Limaye via cfe-commits
https://github.com/hazzlim closed https://github.com/llvm/llvm-project/pull/103088 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-09-04 Thread Nikita Popov via cfe-commits
nikic wrote: Can this be closed in favor of https://github.com/llvm/llvm-project/pull/105496? https://github.com/llvm/llvm-project/pull/103088 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c

[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-08-22 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Oh, I see. If you can prove that it would be illegal to use a negative index with a particular pointer, you might be able to optimize... but I'm not sure how aggressive we want to be here. Even if the C standard technically disallows indexing past the beginning/end of a

[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-08-21 Thread Hari Limaye via cfe-commits
hazzlim wrote: > > adding nuw is also valid for signed indices here > > I don't understand how you think this would work; a-1 and a+-1 are required > to produce the same result. The thinking here RE signed indices was that in this special case, where the base address of the GEP is the start o

[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-08-14 Thread Nikita Popov via cfe-commits
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/103088 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-08-14 Thread Nikita Popov via cfe-commits
@@ -4345,8 +4355,8 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, QualType ptrType = E->getBase()->getType(); Addr = emitArraySubscriptGEP(*this, Addr, Idx, E->getType(), !getLangOpts().isSignedOverflowDe

[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-08-14 Thread Nikita Popov via cfe-commits
https://github.com/nikic commented: As a high level comment: Do we need to pass through the nuw flag, rather than deriving it from signedIndices? Basically, I think that we should be emitting nuw if and only if `-fsanitize=undefined` would perform a check for unsigned overflow for that gep, a

[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-08-13 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > adding nuw is also valid for signed indices here I don't understand how you think this would work; a-1 and a+-1 are required to produce the same result. https://github.com/llvm/llvm-project/pull/103088 ___ cfe-commits mailing l

[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-08-13 Thread Hari Limaye via cfe-commits
hazzlim wrote: This seems correct from my reading of the relevant parts of the C/C++ standard, regarding pointer arithmetic and array subscript expressions. It does actually seem like the restriction to unsigned indices here is actually unnecessary, and adding `nuw` is also valid for signed in

[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-08-13 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-backend-powerpc @llvm/pr-subscribers-clang Author: Hari Limaye (hazzlim) Changes Generate nuw GEPs for array subscript expressions where the base address points to the base of a constant size array and the index is uns

[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-08-13 Thread Hari Limaye via cfe-commits
https://github.com/hazzlim created https://github.com/llvm/llvm-project/pull/103088 Generate nuw GEPs for array subscript expressions where the base address points to the base of a constant size array and the index is unsigned. >From 1eca1fe3d73c9832bde3e09a93f8d0a2a2bb3698 Mon Sep 17 00:00:00