[PATCH] D72787: [BPF] Adjust optimizations to generate kernel verifier friendly codes

Yonghong Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 22:34:01 PDT 2020


yonghong-song added a comment.

In D72787#2083897 <https://reviews.llvm.org/D72787#2083897>, @anakryiko wrote:

> > V >= Lo && V <  Hi --> V - Lo u<  Hi - Lo
> >  V <  Lo || V >= Hi --> V - Lo u>= Hi - Lo
>
> Isn't the following possible as well?
>
> V >= Lo &&  V <= Hi --> V - Lo u<= Hi - Lo
>  V < Lo || V > Hi --> V - Lo u> Hi - Lo
>
> Should the code handle them as well?


This is actually handled. If you have code like

  if (v > 0) { if (v <= 16) ...}

The compiler will first transform it to

  if (v >= 1) { if (v <= 17) ... }

and then do the above transformation.
With the pre-transformation, you limit the downword cases.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72787/new/

https://reviews.llvm.org/D72787





More information about the llvm-commits mailing list