[PATCH] D123559: [DA] Refactor with a better API (NFC)
Michael Kruse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 11 20:05:58 PDT 2022
Meinersbur added a comment.
Note that his is not strictly NFC, `stripPointerCasts` also strips zero GEPs and calls with `returned` attribute, ie. strictly more powerful. For instance:
i32 = getelementpointer i32* %a, i32 0
%bitcast = bitcast i32* %0 to i64*
`stripPointerCasts` on %bitcast would return %a.
================
Comment at: llvm/lib/Analysis/DependenceAnalysis.cpp:3354-3355
Value *DstBasePtr = DstGEP->getOperand(0);
- while (auto *PCast = dyn_cast<BitCastInst>(SrcBasePtr))
- SrcBasePtr = PCast->getOperand(0);
- while (auto *PCast = dyn_cast<BitCastInst>(DstBasePtr))
- DstBasePtr = PCast->getOperand(0);
+ if (auto *PCast = dyn_cast<BitCastInst>(SrcBasePtr))
+ SrcBasePtr = PCast->stripPointerCasts();
+ if (auto *PCast = dyn_cast<BitCastInst>(DstBasePtr))
----------------
No If-condition needed, `stripPointerCasts` will return itself if not strippable.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123559/new/
https://reviews.llvm.org/D123559
More information about the llvm-commits
mailing list