This is an archive of the discontinued LLVM Phabricator instance.

BPF: Workaround InstCombine trunc+icmp => mask+icmp Optimization
ClosedPublic

Authored by yonghong-song on Nov 18 2021, 7:31 PM.

Details

Summary

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

Diff Detail

Event Timeline

yonghong-song created this revision.Nov 18 2021, 7:31 PM
yonghong-song requested review of this revision.Nov 18 2021, 7:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 18 2021, 7:31 PM
ast accepted this revision.Nov 18 2021, 8:04 PM
This revision is now accepted and ready to land.Nov 18 2021, 8:04 PM