[llvm-bugs] [Bug 52455] New: Repeated conditionals are not combined with differing conditionals in between
llvm-bugs at lists.llvm.org
Tue Nov 9 12:34:35 PST 2021
Bug ID: 52455
Summary: Repeated conditionals are not combined with differing
conditionals in between
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: llvm-bugs at bluematt.me
CC: llvm-bugs at lists.llvm.org
In some auto-generated XDP code which (in part) consists of a long list of
conditional -> return XDP_DROP statements, LLVM 13 seems materially worse at
combining parts of the conditionals which are repeated than LLVM 12-, though
both miss some major cases.
The godbolt link at https://godbolt.org/z/hW3r6EKqT demonstrates this using
something that is based on my (real) auto-generated code. In clang 13, the
first part of the repeated conditional is identical and combined, but any parts
after the `ip->saddr` check (which differs across conditionals) is repeated,
almost doubling the number of instructions the BPF verifier has to process.
In clang 12 (and most previous versions), LLVM can sometimes remove the
repeated `dport` check, but only if its the only if `SADDRA_MASK` and
`SADDRB_MASK` are equal or EXTRA_CHECK is empty. In the real auto-generated
code, `SADDRA_MASK` and `SADDRB_MASK` differ across each conditional, and
`EXTRA_CHECK` is something like "ip->protocol == 6 &&", which causes clang
11/12 to repeat the port and protocol checks for each conditional (ie
https://godbolt.org/z/h8d1zesjr which is the same base code as above).
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-bugs