[PATCH] D128364: [InstCombine] Look through more casts when folding memchr and memcmp
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 28 01:21:29 PDT 2022
nikic added inline comments.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:4194
+ const GlobalVariable *GV;
if (const GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {
+ // Drill down into the first operand, ignoring any intervening casts,
----------------
You can move this out of the `GEPOperator` block and also drop the stripPointerCasts() above (and the repeated checks of GV below it). All cases can be treated uniformly.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:4239
+ // library calls to safer expressions. This is preferable to making
+ // the calls although it prevents sanitizers from detecting such calls.
+ Slice.Length = Length < Offset ? 0 : Length - Offset;
----------------
I wouldn't claim that folding these is really "safer", it's just a (UB-based) optimization.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128364/new/
https://reviews.llvm.org/D128364
More information about the llvm-commits
mailing list