[PATCH] D147990: [BPF] Undo transformation for LICM.cpp:hoistMinMax()

Eduard Zingerman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 30 13:17:22 PDT 2023

eddyz87 created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
eddyz87 updated this revision to Diff 512418.
eddyz87 added a comment.
eddyz87 updated this revision to Diff 512451.
eddyz87 updated this revision to Diff 512928.
eddyz87 updated this revision to Diff 513021.
eddyz87 updated this revision to Diff 536282.
eddyz87 published this revision for review.
eddyz87 added a reviewer: yonghong-song.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Update for test case to workaround windows issue

eddyz87 added a comment.

Order of function parameter evaluation is not defined,
this causes issues for test cases (as indicated by windows
test runs).

eddyz87 added a comment.

- removed requirement for one of the min() to be a constant
- added comment on why the transformation is necessary

eddyz87 added a comment.

Update to only operate on loop bodies

irogers added a comment.

The motivation, transformation and tests make sense all look good to me.

eddyz87 added a comment.

Rebase, added a few comments.

eddyz87 added a comment.

Hi Yonghong,

Could you please take a look?
I checked this revision against kernel master and see code generation change in a single test: get_branch_snapshot.c, the test contains pattern in question. No veristat changes for Cilium programs [2].
I also verified that selftests at revision [1] (the last revision before your fixes for `check_cond_jmp_op()`) are passing when using this revision (and loop6 fails if `main` is used instead of this revision).
Unfortunately, after thinking on loop6 behavior a bit more I can't suggest a better solution than this.

[1] 360cd42c4e95 ("io_uring: optimise io_req_local_work_add")
[2] https://github.com/anakryiko/cilium

Extended BPFCheckAndAdjustIR pass with sinkMinMax() transformation
that undoes LICM hoistMinMax pass.

The undo transformation converts the following patterns:

  x < min(a, b) -> x < a && x < b
  x > min(a, b) -> x > a || x > b
  x < max(a, b) -> x < a || x < b
  x > max(a, b) -> x > a && x > b

Where 'a' or 'b' is a constant.
Also supports `sext min(...) ...` and `zext min(...) ...`.

  rG LLVM Github Monorepo



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147990.536282.patch
Type: text/x-patch
Size: 14842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230630/9cf15ae0/attachment-0001.bin>

More information about the llvm-commits mailing list