[PATCH] D143167: [NFCI] Cleanup processing of casts in PHITransAddr
Sergei Kachkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 2 05:19:38 PST 2023
kachkov98 updated this revision to Diff 494266.
kachkov98 added a comment.
Split patch
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143167/new/
https://reviews.llvm.org/D143167
Files:
llvm/lib/Analysis/PHITransAddr.cpp
Index: llvm/lib/Analysis/PHITransAddr.cpp
===================================================================
--- llvm/lib/Analysis/PHITransAddr.cpp
+++ llvm/lib/Analysis/PHITransAddr.cpp
@@ -181,10 +181,12 @@
// Find an available version of this cast.
- // Constants are trivial to find.
- if (Constant *C = dyn_cast<Constant>(PHIIn))
- return addAsInput(
- ConstantExpr::getCast(Cast->getOpcode(), C, Cast->getType()));
+ // Try to simplify cast first.
+ if (Value *V = simplifyCastInst(Cast->getOpcode(), PHIIn, Cast->getType(),
+ {DL, TLI, DT, AC})) {
+ RemoveInstInputs(PHIIn, InstInputs);
+ return addAsInput(V);
+ }
// Otherwise we have to see if a casted version of the incoming pointer
// is available. If so, we can use it, otherwise we have to fail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143167.494266.patch
Type: text/x-patch
Size: 857 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230202/0fed8bba/attachment.bin>
More information about the llvm-commits
mailing list