diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2025-04-07 21:56:00 +0700 |
---|---|---|
committer | Matt Arsenault <arsenm2@gmail.com> | 2025-04-13 17:17:33 +0200 |
commit | 30ae47eeefaeb2c78ae7f234621b8bb0444b7844 (patch) | |
tree | 7181ddf46740cfc3bdcf297616d0499bcbd7c279 | |
parent | 393c783a10052b14d2b76b3ee930b3d83e7f1a16 (diff) | |
download | llvm-30ae47eeefaeb2c78ae7f234621b8bb0444b7844.zip llvm-30ae47eeefaeb2c78ae7f234621b8bb0444b7844.tar.gz llvm-30ae47eeefaeb2c78ae7f234621b8bb0444b7844.tar.bz2 |
SCEVExpander: Don't look at uses of constants (#134691)
This could be more relaxed, and look for uses of globals in
the same function but no tests apparently depend on that.
-rw-r--r-- | llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index 41bf202..e25ec6c 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -111,20 +111,23 @@ Value *SCEVExpander::ReuseOrCreateCast(Value *V, Type *Ty, Value *Ret = nullptr; - // Check to see if there is already a cast! - for (User *U : V->users()) { - if (U->getType() != Ty) - continue; - CastInst *CI = dyn_cast<CastInst>(U); - if (!CI || CI->getOpcode() != Op) - continue; + if (!isa<Constant>(V)) { + // Check to see if there is already a cast! + for (User *U : V->users()) { + if (U->getType() != Ty) + continue; + CastInst *CI = dyn_cast<CastInst>(U); + if (!CI || CI->getOpcode() != Op) + continue; - // Found a suitable cast that is at IP or comes before IP. Use it. Note that - // the cast must also properly dominate the Builder's insertion point. - if (IP->getParent() == CI->getParent() && &*BIP != CI && - (&*IP == CI || CI->comesBefore(&*IP))) { - Ret = CI; - break; + // Found a suitable cast that is at IP or comes before IP. Use it. Note + // that the cast must also properly dominate the Builder's insertion + // point. + if (IP->getParent() == CI->getParent() && &*BIP != CI && + (&*IP == CI || CI->comesBefore(&*IP))) { + Ret = CI; + break; + } } } |