[PATCH] D123818: [InstCombine] Fold strnlen calls in equality to zero.

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 12:07:17 PDT 2022


xbolva00 added inline comments.


================
Comment at: llvm/test/Transforms/InstCombine/strnlen-5.ll:42
 
 ; Fold strnlen(ax, 1) == 0 to *ax == 0.
 
----------------
msebor wrote:
> xbolva00 wrote:
> > What about “strnlen(…) < 1” ? Do we have such test?
> I've added a couple.  I expected `isOnlyUsedInZeroEqualityComparison()` to return true for such expressions but it only handles straight equality.  The case is folded by the subsequent code path but the emitted code is slightly different.  It seems it might be worth looking into enhancing the function to handle both `< 1` and `== 0` with unsigned operands (as well as the converse).
No need as < 1 is always canonicalized to == 0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123818



More information about the llvm-commits mailing list