[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-10-25 Thread Nikita Popov via cfe-commits
@@ -6397,6 +6397,48 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1, return Constant::getNullValue(ReturnType); break; } + case Intrinsic::ptrmask: { +// Fail loudly in case this is ever changed. +// TODO: If vector types are

[clang] [InstCombine] Convert or concat to fshl if opposite or concat exists (PR #68502)

2023-10-24 Thread Nikita Popov via cfe-commits
nikic wrote: > See most recent comments about missing tests. That being said code looks > functionally correct to me. Still not 100% sure this is a desirable change. > Will defer to @nikic about that. I'm also skeptical about accepting this optimization. Looking at the motivating case in

[clang] [ConstantRange] Handle `Intrinsic::cttz` (PR #67917)

2023-10-23 Thread Nikita Popov via cfe-commits
https://github.com/nikic commented: I think most of the comments from the ctpop review also apply to this one. https://github.com/llvm/llvm-project/pull/67917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang-tools-extra] [ConstantRange] Handle `Intrinsic::cttz` (PR #67917)

2023-10-23 Thread Nikita Popov via cfe-commits
https://github.com/nikic commented: I think most of the comments from the ctpop review also apply to this one. https://github.com/llvm/llvm-project/pull/67917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [Clang] Actually fix tests for __builtin_vectorelements (PR #69589)

2023-10-19 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/69589 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Fix __builtin_vectorelements tests with REQUIRES (PR #69582)

2023-10-19 Thread Nikita Popov via cfe-commits
nikic wrote: > @nikic Sorry for the mess :/ > > I took the `target=` approach from > [here](https://llvm.org/docs/TestingGuide.html#constraining-test-execution). > Following the current buildbot status, this also does not seem to crash. Does > this mean the rests are still incorrect and are

[clang] Fix __builtin_vectorelements tests with REQUIRES (PR #69582)

2023-10-19 Thread Nikita Popov via cfe-commits
nikic wrote: The correct check is `REQUIRES: aarch64-registered-target`, not `REQUIRES: target=aarch64`. https://github.com/llvm/llvm-project/pull/69582 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-10-17 Thread Nikita Popov via cfe-commits
nikic wrote: > > We should update LangRef and require that the integer arg has the size of > > the pointer index type > > As in disallow say `ptrmask.p0.i32` on typical systems with 64-bit pointer > index? (So a lot of the current usages). Or something else? Yes, exactly. I've started

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-10-16 Thread Nikita Popov via cfe-commits
nikic wrote: We should update LangRef and require that the integer arg has the size of the pointer index type (with current GEP semantics implying a 1-extend to pointer type width), implement a Verifier check for that, and add an assert in SDAG lowering that the index type size is the pointer

[clang-tools-extra] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-16 Thread Nikita Popov via cfe-commits
@@ -3083,6 +3083,19 @@ ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr( E->getTypeOfArgument()->getPointeeType())) .getQuantity(); return llvm::ConstantInt::get(CGF.SizeTy, Alignment); + } else if (E->getKind() == UETT_VectorElements) { +

[libunwind] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-16 Thread Nikita Popov via cfe-commits
@@ -3083,6 +3083,19 @@ ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr( E->getTypeOfArgument()->getPointeeType())) .getQuantity(); return llvm::ConstantInt::get(CGF.SizeTy, Alignment); + } else if (E->getKind() == UETT_VectorElements) { +

[clang] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-16 Thread Nikita Popov via cfe-commits
@@ -3083,6 +3083,19 @@ ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr( E->getTypeOfArgument()->getPointeeType())) .getQuantity(); return llvm::ConstantInt::get(CGF.SizeTy, Alignment); + } else if (E->getKind() == UETT_VectorElements) { +

[clang] Add Documentation for Execution Results Handling in Clang-Repl (PR #65650)

2023-10-13 Thread Nikita Popov via cfe-commits
nikic wrote: You probably should just use find_program instead of llvm_find_program. It looks like llvm_find_program is used in just a single place, while we have very wide direct use of find_program, so I'm not sure why it is a thing in the first place.

[clang] ac32d7b - Revert "Add Documentation for Execution Results Handling in Clang-Repl (#65650)"

2023-10-13 Thread Nikita Popov via cfe-commits
Author: Nikita Popov Date: 2023-10-13T09:39:00+02:00 New Revision: ac32d7b87f4d4b546eea96b9b722e88fdb3a5b49 URL: https://github.com/llvm/llvm-project/commit/ac32d7b87f4d4b546eea96b9b722e88fdb3a5b49 DIFF: https://github.com/llvm/llvm-project/commit/ac32d7b87f4d4b546eea96b9b722e88fdb3a5b49.diff

[clang] Add Documentation for Execution Results Handling in Clang-Repl (PR #65650)

2023-10-13 Thread Nikita Popov via cfe-commits
nikic wrote: Actually no, that's not possible as config-ix modules are explicitly private to their subproject and should not be used outside them. I'm going to revert this change due to this layering violation. https://github.com/llvm/llvm-project/pull/65650

[clang] Add Documentation for Execution Results Handling in Clang-Repl (PR #65650)

2023-10-13 Thread Nikita Popov via cfe-commits
nikic wrote: This also breaks the clang standalone build. You need to `include(config-ix)` in order to use `llvm_find_program`. https://github.com/llvm/llvm-project/pull/65650 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2023-10-12 Thread Nikita Popov via cfe-commits
@@ -6,15 +6,16 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:32-f3 define ptr@test1(ptr %A, i32 %Offset) { ; CHECK-LABEL: @test1( ; CHECK-NEXT: entry: +; CHECK-NEXT:[[TMP:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i32

[clang] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2023-10-12 Thread Nikita Popov via cfe-commits
@@ -637,9 +637,8 @@ define ptr @select_of_gep(i1 %c, ptr %p) { define ptr @select_of_gep_different_type(i1 %c, ptr %p) { ; CHECK-LABEL: @select_of_gep_different_type( -; CHECK-NEXT:[[GEP1:%.*]] = getelementptr i32, ptr [[P:%.*]], i64 1 -; CHECK-NEXT:[[GEP2:%.*]] =

[clang] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2023-10-12 Thread Nikita Popov via cfe-commits
@@ -597,14 +598,13 @@ define ptr @gep_of_phi_of_gep_different_type(i1 %c, ptr %p) { ; CHECK-LABEL: @gep_of_phi_of_gep_different_type( ; CHECK-NEXT:br i1 [[C:%.*]], label [[IF:%.*]], label [[ELSE:%.*]] ; CHECK: if: -; CHECK-NEXT:[[GEP1:%.*]] = getelementptr i32,

[clang] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2023-10-12 Thread Nikita Popov via cfe-commits
https://github.com/nikic commented: I looked through the test diffs, and it seems like the only substantial regressions are all related to the indexed compare fold, which should be made type-independent. https://github.com/llvm/llvm-project/pull/68882

[clang] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2023-10-12 Thread Nikita Popov via cfe-commits
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/68882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2023-10-12 Thread Nikita Popov via cfe-commits
@@ -3,8 +3,9 @@ define ptr @f1(ptr %arg, i64 %arg1) { ; CHECK-LABEL: @f1( -; CHECK-NEXT:[[TMP1:%.*]] = getelementptr [6 x i32], ptr [[ARG:%.*]], i64 3, i64 [[ARG1:%.*]] -; CHECK-NEXT:ret ptr [[TMP1]] +; CHECK-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[ARG:%.*]],

[clang] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2023-10-12 Thread Nikita Popov via cfe-commits
@@ -560,14 +560,15 @@ define i32 @test28() nounwind { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[ORIENTATIONS:%.*]] = alloca [1 x [1 x %struct.x]], align 8 ; CHECK-NEXT:[[T3:%.*]] = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str) #[[ATTR0]] +; CHECK-NEXT:

[clang] e44c9fd - [Clang] Regenerate test checks (NFC)

2023-10-12 Thread Nikita Popov via cfe-commits
Author: Nikita Popov Date: 2023-10-12T14:24:26+02:00 New Revision: e44c9fd197a2209b6b7b266fb0a381ee8fcec12b URL: https://github.com/llvm/llvm-project/commit/e44c9fd197a2209b6b7b266fb0a381ee8fcec12b DIFF: https://github.com/llvm/llvm-project/commit/e44c9fd197a2209b6b7b266fb0a381ee8fcec12b.diff

[clang] [InstCombine] Canonicalize `(X +/- Y) & Y` into `~X & Y` when Y is a power of 2 (PR #67915)

2023-10-12 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/67915 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [InstCombine] Canonicalize `(X +/- Y) & Y` into `~X & Y` when Y is a power of 2 (PR #67915)

2023-10-12 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/67915 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Clean up strange uses of getAnalysisIfAvailable (PR #65729)

2023-10-11 Thread Nikita Popov via cfe-commits
nikic wrote: > GVN seems to have different behavior regarding LoopInfo in the LegacyPM and > NewPM, but that's an orthogonal issue. I'll check whether always requiring > LoopInfo in GVN has any compile-time impact, as I don't think this is > supposed to be an optional analysis there

[clang-tools-extra] llvm-canon (PR #68176)

2023-10-09 Thread Nikita Popov via cfe-commits
nikic wrote: Using the term for MIR is okay, because it does not have a pre-existing notion of canonical form. Doing the same for IR is not okay, because it already has a canonical form and this pass does not produce it. Calling this `ir-normalizer` instead of `ir-canonicalizer` should convey

[clang] llvm-canon (PR #68176)

2023-10-09 Thread Nikita Popov via cfe-commits
nikic wrote: Using the term for MIR is okay, because it does not have a pre-existing notion of canonical form. Doing the same for IR is not okay, because it already has a canonical form and this pass does not produce it. Calling this `ir-normalizer` instead of `ir-canonicalizer` should convey

[clang] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)

2023-10-06 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. Yeah, it looks correct now. https://github.com/llvm/llvm-project/pull/65852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)

2023-10-06 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. Yeah, it looks correct now. https://github.com/llvm/llvm-project/pull/65852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)

2023-10-06 Thread Nikita Popov via cfe-commits
nikic wrote: Looks like incorrect conflict resolution in the last merge. https://github.com/llvm/llvm-project/pull/65852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)

2023-10-06 Thread Nikita Popov via cfe-commits
nikic wrote: Looks like incorrect conflict resolution in the last merge. https://github.com/llvm/llvm-project/pull/65852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [InstCombine] Canonicalize `(X +/- Y) & Y` into `~X & Y` when Y is a power of 2 (PR #67915)

2023-10-06 Thread Nikita Popov via cfe-commits
nikic wrote: Can you please pre-commit the new tests as well (and double-check that there is no unexpected operand order canonicalization while doing that)? https://github.com/llvm/llvm-project/pull/67915 ___ cfe-commits mailing list

[clang-tools-extra] [InstCombine] Canonicalize `(X +/- Y) & Y` into `~X & Y` when Y is a power of 2 (PR #67915)

2023-10-06 Thread Nikita Popov via cfe-commits
https://github.com/nikic commented: Seems like some test coverage is missing here? * Commuted add * Commuted sub (negative test) * Commuted and * Multi-use add (negative test) https://github.com/llvm/llvm-project/pull/67915 ___ cfe-commits mailing

[clang-tools-extra] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)

2023-10-05 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. Basically LGTM, but I think this is still missing negative tests for non-equality pred1/pred2? https://github.com/llvm/llvm-project/pull/65852 ___ cfe-commits mailing list

[clang] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)

2023-10-05 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. Basically LGTM, but I think this is still missing negative tests for non-equality pred1/pred2? https://github.com/llvm/llvm-project/pull/65852 ___ cfe-commits mailing list

[clang] [clang] Replace uses of CreatePointerBitCastOrAddrSpaceCast (NFC) (PR #68277)

2023-10-05 Thread Nikita Popov via cfe-commits
@@ -2138,6 +2138,8 @@ class IRBuilderBase { return Insert(CastInst::CreatePointerCast(V, DestTy), Name); } + // With opaque pointers enabled, this is same as CreateAddressSpaceCast. nikic wrote: All the IRBuilder cast methods are no-ops if old type ==

[clang] llvm-canon (PR #68176)

2023-10-05 Thread Nikita Popov via cfe-commits
nikic wrote: Please don't use the term canon/canonicalize for this pass or tool. LLVM has an existing notion of "canonicalization" which does coincide with what is being done here. https://github.com/llvm/llvm-project/pull/68176 ___ cfe-commits

[clang] [Clang][Driver] Add new flags to control IR verification (PR #68172)

2023-10-04 Thread Nikita Popov via cfe-commits
@@ -146,6 +146,13 @@ Non-comprehensive list of changes in this release New Compiler Flags -- +* ``-fverify-intermediate-code`` and it's complement ``-fno-verify-intermediate-code``. + Enables or disables verification of the generated LLVM IR. + It's

[clang] [Clang][Driver] Add new flags to control IR verification (PR #68172)

2023-10-04 Thread Nikita Popov via cfe-commits
@@ -146,6 +146,13 @@ Non-comprehensive list of changes in this release New Compiler Flags -- +* ``-fverify-intermediate-code`` and it's complement ``-fno-verify-intermediate-code``. + Enables or disables verification of the generated LLVM IR. + It's

[clang] [Clang][Driver] Add new flags to control IR verification (PR #68172)

2023-10-04 Thread Nikita Popov via cfe-commits
@@ -146,6 +146,13 @@ Non-comprehensive list of changes in this release New Compiler Flags -- +* ``-fverify-intermediate-code`` and it's complement ``-fno-verify-intermediate-code``. + Enables or disables verification of the generated LLVM IR. + It's

[clang] [CodeGen] Respect pointer-overflow sanitizer for void pointers (PR #67772)

2023-10-04 Thread Nikita Popov via cfe-commits
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/67772 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Inliner] Improve propagation of return attributes. (PR #67756)

2023-10-03 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/67756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Inliner] Improve propagation of return attributes. (PR #67756)

2023-10-03 Thread Nikita Popov via cfe-commits
nikic wrote: (Another alternative would be to use different check-prefixes for C/C++) https://github.com/llvm/llvm-project/pull/67756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Inliner] Improve propagation of return attributes. (PR #67756)

2023-10-03 Thread Nikita Popov via cfe-commits
nikic wrote: It looks like x86-bswap.c still has the C++ guarded code in it. Any thoughts on > Though I think we might be better off passing `-no-enable-noundef-analysis` > to these tests, as noundef is really not what they want to test. to avoid the test duplication?

[clang] -fsanitize=alignment: check memcpy/memmove arguments (PR #67766)

2023-10-02 Thread Nikita Popov via cfe-commits
nikic wrote: @zygoloid Thanks for the explanation! I wasn't aware this fell under unspecified behavior. It's weird that alignment information can survive a `void *` cast, but it does make some sense. What seems worrying here is that apparently GCC and Clang do not agree on semantics in this

[clang] Introduce paged vector (PR #66430)

2023-10-02 Thread Nikita Popov via cfe-commits
nikic wrote: > I also noticed that LoadedSLocEntryTable uses 42 elements tables, which > probably introduces some extra divisions to do the indexing. I can try > switching to 32 elements. I've tested the following change that forces power of two pages sizes, but it did not have any impact:

[clang] [Inliner] Improve propagation of return attributes. (PR #67756)

2023-10-02 Thread Nikita Popov via cfe-commits
nikic wrote: Apart from that, the functional changes themselves look good to me. https://github.com/llvm/llvm-project/pull/67756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Inliner] Improve propagation of return attributes. (PR #67756)

2023-10-02 Thread Nikita Popov via cfe-commits
nikic wrote: For the clang tests you've split, the `.c` versions still have `defined(__cplusplus)` checks, which doesn't make much sense. Though I think we might be better off passing `-no-enable-noundef-analysis` to these tests, as noundef is really not what they want to test.

[clang] 3b25407 - [IR] Mark zext/sext constant expressions as undesirable

2023-10-02 Thread Nikita Popov via cfe-commits
Author: Nikita Popov Date: 2023-10-02T12:40:20+02:00 New Revision: 3b25407d977d9ed3dbcaccd4f8850b65e95d70fd URL: https://github.com/llvm/llvm-project/commit/3b25407d977d9ed3dbcaccd4f8850b65e95d70fd DIFF: https://github.com/llvm/llvm-project/commit/3b25407d977d9ed3dbcaccd4f8850b65e95d70fd.diff

[clang-tools-extra] [Support] Add KnownBits::computeForSubBorrow (PR #67788)

2023-10-01 Thread Nikita Popov via cfe-commits
@@ -3732,14 +3732,18 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt , assert(Op.getResNo() == 0 && "We only compute knownbits for the difference here."); -// TODO: Compute influence of the carry operand. -if (Opcode ==

[libunwind] [Support] Add KnownBits::computeForSubBorrow (PR #67788)

2023-10-01 Thread Nikita Popov via cfe-commits
@@ -3732,14 +3732,18 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt , assert(Op.getResNo() == 0 && "We only compute knownbits for the difference here."); -// TODO: Compute influence of the carry operand. -if (Opcode ==

[clang] [Support] Add KnownBits::computeForSubBorrow (PR #67788)

2023-10-01 Thread Nikita Popov via cfe-commits
@@ -3732,14 +3732,18 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt , assert(Op.getResNo() == 0 && "We only compute knownbits for the difference here."); -// TODO: Compute influence of the carry operand. -if (Opcode ==

[clang-tools-extra] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)

2023-09-30 Thread Nikita Popov via cfe-commits
@@ -6380,7 +6380,71 @@ Instruction *InstCombinerImpl::foldICmpUsingBoolRange(ICmpInst ) { Y->getType()->isIntOrIntVectorTy(1) && Pred == ICmpInst::ICMP_ULE) return BinaryOperator::CreateOr(Builder.CreateIsNull(X), Y); + // icmp eq/ne X, (zext/sext (icmp eq/ne X,

[clang-tools-extra] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)

2023-09-30 Thread Nikita Popov via cfe-commits
@@ -6380,7 +6380,71 @@ Instruction *InstCombinerImpl::foldICmpUsingBoolRange(ICmpInst ) { Y->getType()->isIntOrIntVectorTy(1) && Pred == ICmpInst::ICMP_ULE) return BinaryOperator::CreateOr(Builder.CreateIsNull(X), Y); + // icmp eq/ne X, (zext/sext (icmp eq/ne X,

[clang] Introduce paged vector (PR #66430)

2023-09-30 Thread Nikita Popov via cfe-commits
nikic wrote: Looks like this causes a compile-time regression: https://llvm-compile-time-tracker.com/compare.php?from=abcaebfe3aacb13d46be5e949fd6ed9b4321e2f6=4ae51570806ba5c5fcabe6d6dcbe52e3a5d5453b=instructions%3Au About 0.5% at `O0`. https://github.com/llvm/llvm-project/pull/66430

[clang] -fsanitize=alignment: check memcpy/memmove arguments (PR #67766)

2023-09-29 Thread Nikita Popov via cfe-commits
nikic wrote: Uh, why are we allowed to assume that memcpy pointer arguments are aligned? This looks like a miscompile to me. A plain `int *` pointer is not required to be aligned, and memcpy works on `void *` pointers, so I'm not sure where an alignment requirement would appear from.

[clang-tools-extra] [Support] Add KnownBits::computeForSubBorrow (PR #67788)

2023-09-29 Thread Nikita Popov via cfe-commits
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/67788 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Support] Add KnownBits::computeForSubBorrow (PR #67788)

2023-09-29 Thread Nikita Popov via cfe-commits
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/67788 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [Support] Add KnownBits::computeForSubBorrow (PR #67788)

2023-09-29 Thread Nikita Popov via cfe-commits
@@ -3732,14 +3732,18 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt , assert(Op.getResNo() == 0 && "We only compute knownbits for the difference here."); -// TODO: Compute influence of the carry operand. -if (Opcode ==

[clang] [Support] Add KnownBits::computeForSubBorrow (PR #67788)

2023-09-29 Thread Nikita Popov via cfe-commits
https://github.com/nikic commented: Looks fine to me. https://github.com/llvm/llvm-project/pull/67788 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Support] Add KnownBits::computeForSubBorrow (PR #67788)

2023-09-29 Thread Nikita Popov via cfe-commits
@@ -3732,14 +3732,18 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt , assert(Op.getResNo() == 0 && "We only compute knownbits for the difference here."); -// TODO: Compute influence of the carry operand. -if (Opcode ==

[clang] [CodeGen] Respect pointer-overflow sanitizer for void pointers (PR #67772)

2023-09-29 Thread Nikita Popov via cfe-commits
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/67772 Pointer arithmetic on void pointers (a GNU extension) was going through a different code path and bypassed the pointer-overflow sanitizer. Fixes https://github.com/llvm/llvm-project/issues/66451. >From

[clang] fb2bdbb - [CodeGen] Avoid use of ConstantExpr::getZExt() (NFC)

2023-09-28 Thread Nikita Popov via cfe-commits
Author: Nikita Popov Date: 2023-09-28T16:45:31+02:00 New Revision: fb2bdbb83d3913d9d32b28c1de3f3d8b4e6dfc8a URL: https://github.com/llvm/llvm-project/commit/fb2bdbb83d3913d9d32b28c1de3f3d8b4e6dfc8a DIFF: https://github.com/llvm/llvm-project/commit/fb2bdbb83d3913d9d32b28c1de3f3d8b4e6dfc8a.diff

[clang] [SCCP] [Transform] Adding ICMP folding for zext and sext in SCCPSolver (PR #67594)

2023-09-27 Thread Nikita Popov via cfe-commits
https://github.com/nikic requested changes to this pull request. If I understood correctly, what you're trying to do here is to apply an icmp fold early before the sext -> zext information gets lost. I don't think this is the correct way to approach the problem. The correct way is to preserve

[clang] [CodeGenPrepare] Transform ldexp into target supported intrinsics (PR #67552)

2023-09-27 Thread Nikita Popov via cfe-commits
nikic wrote: Why does this need special handling in CGP instead of being a normal custom lowering for FLDEXP? https://github.com/llvm/llvm-project/pull/67552 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-26 Thread Nikita Popov via cfe-commits
@@ -6397,6 +6397,48 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1, return Constant::getNullValue(ReturnType); break; } + case Intrinsic::ptrmask: { +// Fail loudly in case this is ever changed. +// TODO: If vector types are

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-26 Thread Nikita Popov via cfe-commits
@@ -6397,6 +6397,48 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1, return Constant::getNullValue(ReturnType); break; } + case Intrinsic::ptrmask: { +// Fail loudly in case this is ever changed. +// TODO: If vector types are

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-26 Thread Nikita Popov via cfe-commits
https://github.com/nikic resolved https://github.com/llvm/llvm-project/pull/67166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-26 Thread Nikita Popov via cfe-commits
https://github.com/nikic resolved https://github.com/llvm/llvm-project/pull/67166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-26 Thread Nikita Popov via cfe-commits
@@ -898,6 +910,53 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, } break; } + case Intrinsic::ptrmask: { +// Fail loudly in case this is ever changed. +// Likely not much needs to be changed here to

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-26 Thread Nikita Popov via cfe-commits
https://github.com/nikic resolved https://github.com/llvm/llvm-project/pull/67166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-26 Thread Nikita Popov via cfe-commits
https://github.com/nikic resolved https://github.com/llvm/llvm-project/pull/67166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-26 Thread Nikita Popov via cfe-commits
@@ -6397,6 +6397,48 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1, return Constant::getNullValue(ReturnType); break; } + case Intrinsic::ptrmask: { +// Fail loudly in case this is ever changed. +// TODO: If vector types are

[clang] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)

2023-09-24 Thread Nikita Popov via cfe-commits
@@ -6380,7 +6380,69 @@ Instruction *InstCombinerImpl::foldICmpUsingBoolRange(ICmpInst ) { Y->getType()->isIntOrIntVectorTy(1) && Pred == ICmpInst::ICMP_ULE) return BinaryOperator::CreateOr(Builder.CreateIsNull(X), Y); + // icmp eq/ne X, (zext/sext (icmp eq/ne X,

[clang-tools-extra] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)

2023-09-24 Thread Nikita Popov via cfe-commits
@@ -6380,7 +6380,69 @@ Instruction *InstCombinerImpl::foldICmpUsingBoolRange(ICmpInst ) { Y->getType()->isIntOrIntVectorTy(1) && Pred == ICmpInst::ICMP_ULE) return BinaryOperator::CreateOr(Builder.CreateIsNull(X), Y); + // icmp eq/ne X, (zext/sext (icmp eq/ne X,

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-24 Thread Nikita Popov via cfe-commits
@@ -898,6 +910,53 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, } break; } + case Intrinsic::ptrmask: { +// Fail loudly in case this is ever changed. +// Likely not much needs to be changed here to

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-24 Thread Nikita Popov via cfe-commits
@@ -6397,6 +6397,48 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1, return Constant::getNullValue(ReturnType); break; } + case Intrinsic::ptrmask: { +// Fail loudly in case this is ever changed. +// TODO: If vector types are

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-24 Thread Nikita Popov via cfe-commits
@@ -1985,6 +1985,28 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst ) { {InnerPtr, NewMask})); } } +bool Changed = false; +KnownBits Known = computeKnownBits(II, /*Depth*/ 0, II); +// See if we can deduce

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-24 Thread Nikita Popov via cfe-commits
@@ -1985,6 +1985,28 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst ) { {InnerPtr, NewMask})); } } +bool Changed = false; +KnownBits Known = computeKnownBits(II, /*Depth*/ 0, II); +// See if we can deduce

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-24 Thread Nikita Popov via cfe-commits
@@ -1985,6 +1985,28 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst ) { {InnerPtr, NewMask})); } } +bool Changed = false; +KnownBits Known = computeKnownBits(II, /*Depth*/ 0, II); +// See if we can deduce

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-24 Thread Nikita Popov via cfe-commits
@@ -1984,10 +1984,30 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst ) { //-> (ptrmask p, (and A, B)) if (match(Op0, m_OneUse(m_Intrinsic( m_Value(InnerPtr), m_Value(InnerMask) { + // See if combining the two masks is free.

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-24 Thread Nikita Popov via cfe-commits
@@ -6397,6 +6397,48 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1, return Constant::getNullValue(ReturnType); break; } + case Intrinsic::ptrmask: { +// Fail loudly in case this is ever changed. +// TODO: If vector types are

[clang] [InstCombine] Add combines/simplifications for `llvm.ptrmask` (PR #67166)

2023-09-24 Thread Nikita Popov via cfe-commits
@@ -6397,6 +6397,48 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1, return Constant::getNullValue(ReturnType); break; } + case Intrinsic::ptrmask: { +// Fail loudly in case this is ever changed. +// TODO: If vector types are

[clang-tools-extra] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)

2023-09-19 Thread Nikita Popov via cfe-commits
@@ -6309,7 +6309,69 @@ Instruction *InstCombinerImpl::foldICmpUsingBoolRange(ICmpInst ) { Y->getType()->isIntOrIntVectorTy(1) && Pred == ICmpInst::ICMP_ULE) return BinaryOperator::CreateOr(Builder.CreateIsNull(X), Y); + ICmpInst::Predicate Pred1, Pred2; const

[clang] [InstCombine] Canonicalize `and(zext(A), B)` into `select A, B & 1, 0` (PR #66740)

2023-09-19 Thread Nikita Popov via cfe-commits
nikic wrote: I think this is the right canonicalization at the IR level, as select allows better analysis than zext(icmp). However, this seems to be universally worse for the backend: https://llvm.godbolt.org/z/Yh7brfc8b So I think we would need an SDAG undo transform. Interestingly, this

[clang] [Inliner] Improve attribute propagation to callsites when inlining. (PR #66036)

2023-09-18 Thread Nikita Popov via cfe-commits
nikic wrote: > ``` > define noundef nonnull ptr @foo() { >%b = call ptr @bar() >call void @use(ptr %p) willreturn nounwind >ret ptr %b > } > ``` > > If we add `nonnull` to `@bar` during inlining it can still make `%p` poison > for its use in `@use`. I get it will trigger proper UB

[clang] [Inliner] Improve attribute propagation to callsites when inlining. (PR #66036)

2023-09-18 Thread Nikita Popov via cfe-commits
nikic wrote: > > It occurs to me that the current return attribute propagation is currently > > buggy for poison-generating attributes: https://llvm.godbolt.org/z/x8n18q9Mj > > In this case the argument to use() will now be poison as well, while before > > inlining only the return value was

[clang] [InstCombine] Fix transforms of two select patterns (PR #65845)

2023-09-17 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/65845 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Inliner] Improve attribute propagation to callsites when inlining. (PR #66036)

2023-09-15 Thread Nikita Popov via cfe-commits
nikic wrote: It occurs to me that the current return attribute propagation is currently buggy for poison-generating attributes: https://llvm.godbolt.org/z/x8n18q9Mj In this case the argument to use() will now be poison as well, while before inlining only the return value was poison. This

[clang] Introduce paged vector (PR #66430)

2023-09-15 Thread Nikita Popov via cfe-commits
nikic wrote: Any numbers on what / how much this improves? https://github.com/llvm/llvm-project/pull/66430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-14 Thread Nikita Popov via cfe-commits
https://github.com/nikic review_requested https://github.com/llvm/llvm-project/pull/65748 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-14 Thread Nikita Popov via cfe-commits
https://github.com/nikic review_request_removed https://github.com/llvm/llvm-project/pull/65748 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-14 Thread Nikita Popov via cfe-commits
https://github.com/nikic review_request_removed https://github.com/llvm/llvm-project/pull/65748 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-14 Thread Nikita Popov via cfe-commits
https://github.com/nikic review_request_removed https://github.com/llvm/llvm-project/pull/65748 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] 14cc7a0 - [Clang] Allow __declspec(noalias) to access inaccessible memory

2023-08-29 Thread Nikita Popov via cfe-commits
Author: Nikita Popov Date: 2023-08-29T11:43:57+02:00 New Revision: 14cc7a07727555102c52e711f476ec7671317d6a URL: https://github.com/llvm/llvm-project/commit/14cc7a07727555102c52e711f476ec7671317d6a DIFF: https://github.com/llvm/llvm-project/commit/14cc7a07727555102c52e711f476ec7671317d6a.diff

[clang] 13a044c - [DebugInfo] Fix incorrect dbg.declare when nrvo flag is used

2023-08-29 Thread Nikita Popov via cfe-commits
Author: Nikita Popov Date: 2023-08-29T11:39:59+02:00 New Revision: 13a044c6993a914fc33549b72215e698a1cdef63 URL: https://github.com/llvm/llvm-project/commit/13a044c6993a914fc33549b72215e698a1cdef63 DIFF: https://github.com/llvm/llvm-project/commit/13a044c6993a914fc33549b72215e698a1cdef63.diff

[clang] fa1b6e6 - [X86] Fix i128 argument passing under SysV ABI

2023-08-21 Thread Nikita Popov via cfe-commits
Author: Nikita Popov Date: 2023-08-21T11:44:35+02:00 New Revision: fa1b6e6b34eb6382c451f3a06a7c52d7ac6ada1d URL: https://github.com/llvm/llvm-project/commit/fa1b6e6b34eb6382c451f3a06a7c52d7ac6ada1d DIFF: https://github.com/llvm/llvm-project/commit/fa1b6e6b34eb6382c451f3a06a7c52d7ac6ada1d.diff

[clang] 063b37e - Reapply [IR] Mark and/or constant expressions as undesirable

2023-07-31 Thread Nikita Popov via cfe-commits
Author: Nikita Popov Date: 2023-07-31T09:54:24+02:00 New Revision: 063b37e7b40ace03184923213bc9ead6aadee540 URL: https://github.com/llvm/llvm-project/commit/063b37e7b40ace03184923213bc9ead6aadee540 DIFF: https://github.com/llvm/llvm-project/commit/063b37e7b40ace03184923213bc9ead6aadee540.diff

<    1   2   3   4   5   6   7   8   >