[PATCH] D114215: BPF: Workaround InstCombine trunc+icmp => mask+icmp Optimization

Yonghong Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 18 19:31:26 PST 2021


yonghong-song created this revision.
yonghong-song added reviewers: ast, anakryiko.
Herald added a subscriber: hiraditya.
yonghong-song requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Patch [1] added further InstCombine trunc+icmp => mask+icmp
optimization and this caused a couple of bpf selftest failure.
Previous llvm BPF backend patch [2] introduced llvm.bpf.compare
builtin to handle such situations.

This patch further added support ">" and ">=" icmp opcodes.
Tested with bpf selftests and all tests are passed including two 
previously failed ones.

Note Patch [1] also added optimization if the to-be-compared
constant is negative-power-of-2 (-C) or not-of-power-of-2 (~C).
This patch didn't implement these two cases as typical bpf 
program compares a scalar to a positive length or boundary value,
and this scalar later is used as a index into an array buffer
or packet buffer.

  [1] https://reviews.llvm.org/D112634
  [2] https://reviews.llvm.org/D112938


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114215

Files:
  llvm/lib/Target/BPF/BPFAdjustOpt.cpp
  llvm/test/CodeGen/BPF/adjust-opt-icmp4.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114215.388364.patch
Type: text/x-patch
Size: 3658 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211119/21c7bf4f/attachment.bin>


More information about the llvm-commits mailing list