[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-13 Thread Björn Pettersson via cfe-commits
bjope wrote: > > Here is another thing that I noticed after this patch: > > https://godbolt.org/z/1P7bnKGjh > > So early instcombine is eliminating an `and` operation (in the foo > > example), resulting in simplifycfg not being able to collapse the control > > flow any longer. > > I don't thi

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-13 Thread Björn Pettersson via cfe-commits
bjope wrote: Here is another thing that I noticed after this patch: https://godbolt.org/z/1P7bnKGjh So early instcombine is eliminating an `and` operation (in the foo example), resulting in simplifycfg not being able to collapse the control flow any longer. Maybe I should file a separate issu

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-13 Thread via cfe-commits
joanahalili wrote: heads-up, we are seeing some performance regressions due to this patch 8about 6-7%! We will add more details about this soon. https://github.com/llvm/llvm-project/pull/73662 ___ cfe-commits mailing list cfe-commits@lists.llvm.org ht

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-13 Thread Nikita Popov via cfe-commits
nikic wrote: @eddyz87 Right, this is exactly the change I have been working on, see https://github.com/llvm/llvm-project/pull/75311. Unfortunately, it doesn't actually fix the BPF case, because that one involves a loop, and LVI is currently terrible at handling those. (Basically, even though t

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-11 Thread via cfe-commits
yonghong-song wrote: > @yonghong-song I think it may be possible to improve CVP to handle this > better, in which case we won't need BPF workarounds. I'll look into it. @nikic and @bjope. Indeed, https://github.com/llvm/llvm-project/pull/75039 didn't resolve the issue and the generated bpf cod

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-11 Thread Björn Pettersson via cfe-commits
bjope wrote: > @bjope It looks like the InstCombine changes enable IndVars to perform LFTR, > which is unprofitable in this case. Though the `umax(1)` call is actually > completely unnecessary here, but SCEV doesn't realize it. I've put up #75039 > to fix that. Does that improve things for you

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-11 Thread Nikita Popov via cfe-commits
nikic wrote: @yonghong-song I think it may be possible to improve CVP to handle this better, in which case we won't need BPF workarounds. I'll look into it. https://github.com/llvm/llvm-project/pull/73662 ___ cfe-commits mailing list cfe-commits@lists

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-10 Thread via cfe-commits
yonghong-song wrote: Hi, @nikic, This patch caused a bpf verifier regression with one of bpf selftests. The details can be found in kernel bpf mailing list. https://lore.kernel.org/bpf/0ff5f011-7524-4550-89eb-bb2c89f69...@linux.dev/ Note that bpf verification failure here does not mean that

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-06 Thread Nikita Popov via cfe-commits
nikic wrote: Okay, it looks like the mpeg2decode regression is indeed fixed. I think the only somewhat significant regression left is `Shootout-C++-ary2`, but in my IR diffs I don't see any regression there (only improvements with a bunch of conditions being optimized away). https://github.co

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

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

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-05 Thread Nikita Popov via cfe-commits
nikic wrote: I've put up https://github.com/llvm/llvm-project/pull/74467 to use disjoint in SCEV. https://github.com/llvm/llvm-project/pull/73662 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/c

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-04 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff f368e6424fbfb7fdea4b9d9a2e44f2f7e188c133 3575ad5701a852dd8b79d144ea17a729cfb4d94c --

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-04 Thread Nikita Popov via cfe-commits
nikic wrote: > Could you please rebase this patch on #74246 and add a test for #74242? Done. The new test is `@div_by_zero_or_one_from_dom_cond`. https://github.com/llvm/llvm-project/pull/73662 ___ cfe-commits mailing list cfe-commits@lists.llvm.org h

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-01 Thread Yingwei Zheng via cfe-commits
dtcxzyw wrote: My CI detected some significant regressions caused by this patch: https://github.com/dtcxzyw/llvm-ci/pull/839#issuecomment-1836976355 https://github.com/llvm/llvm-project/pull/73662 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-12-01 Thread Yingwei Zheng via cfe-commits
https://github.com/dtcxzyw approved this pull request. The implementation looks good to me. Waiting for the result of my CI. https://github.com/dtcxzyw/llvm-ci/actions/runs/7066692655 @goldsteinn Any comments? https://github.com/llvm/llvm-project/pull/73662

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-11-29 Thread Nikita Popov via cfe-commits
nikic wrote: > Just realized that this doesn't cover uses of isKnownNonNegative() in > InstCombine yet, as it currently doesn't go through SimplifyQuery. I'll see > about migrating those APIs tomorrow. This is done now, but introduced an additional regression in idioms.ll. https://github.com/

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-11-28 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-llvm-analysis @llvm/pr-subscribers-clang Author: Nikita Popov (nikic) Changes This adds support for using dominating conditions in computeKnownBits() when called from InstCombine. The implementation uses a DomConditionCache, which stores which branches

[llvm] [clang] [ValueTracking] Add dominating condition support in computeKnownBits() (PR #73662)

2023-11-28 Thread Nikita Popov via cfe-commits
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/73662 This adds support for using dominating conditions in computeKnownBits() when called from InstCombine. The implementation uses a DomConditionCache, which stores which branches may provide information that is relevan