[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
Thu Jun 23 08:27:30 PDT 2022
nikic added inline comments.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:4196
+ Op0 = Op0->stripPointerCasts();
const GlobalVariable *GV = dyn_cast<GlobalVariable>(Op0);
if (!GV)
----------------
msebor wrote:
> efriedma wrote:
> > Maybe it makes sense to just drop the `dyn_cast<GlobalVariable>` here?
> This is what I meant by the simplification opportunity (I think we discussed it with @nikic in another review but I should have made that clear here). As far as I can tell the `GlobalVariable` cast is necessary to get at the `DataLayout` and to compute the offset below. (Or is there some other way to get at it?)
If you really want to avoid the DataLayout argument, you can do something like `dyn_cast<GlobalVariable>(getUnderlyingObject(V))`, take the DataLayout from there, and then use that to feed the `stripAndAccumulateConstantOffsets()` call.
Otherwise this is just shifting the problem to a `GEP + bitcast + GEP` sequence. (And it's worth noting that with opaque pointers the casts being skipped here don't exist anyway.)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128364/new/
https://reviews.llvm.org/D128364
More information about the llvm-commits
mailing list