summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2019-05-08 20:59:21 +0000
committerCraig Topper <craig.topper@intel.com>2019-05-08 20:59:21 +0000
commit51a17df45d198731ca9dc691ef90b38c4d0810ac (patch)
tree29b4fc3dedac11a7ae6557323a408e845bd15aa7
parent73b7272e7a87be08e4f5775dbd163685d57558a1 (diff)
downloadbcm5719-llvm-51a17df45d198731ca9dc691ef90b38c4d0810ac.tar.gz
bcm5719-llvm-51a17df45d198731ca9dc691ef90b38c4d0810ac.zip
[InstCombine] When turning sext into zext due to known bits, return the new ZExt instead of calling replaceinstuseswith
The worklist loop that we're returning back to should be able to do the repacement itself. This is how we normally do replacements. My main motivation was that I observed that we weren't preserving the name of the result when we do this transform. The replacement code in the worklist loop will call takeName as part of the replacement. Differential Revision: https://reviews.llvm.org/D61695 llvm-svn: 360284
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 91fdda45ac7..1faaf0bf6af 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1372,10 +1372,8 @@ Instruction *InstCombiner::visitSExt(SExtInst &CI) {
// If we know that the value being extended is positive, we can use a zext
// instead.
KnownBits Known = computeKnownBits(Src, 0, &CI);
- if (Known.isNonNegative()) {
- Value *ZExt = Builder.CreateZExt(Src, DestTy);
- return replaceInstUsesWith(CI, ZExt);
- }
+ if (Known.isNonNegative())
+ return CastInst::Create(Instruction::ZExt, Src, DestTy);
// Try to extend the entire expression tree to the wide destination type.
if (shouldChangeType(SrcTy, DestTy) && canEvaluateSExtd(Src, DestTy)) {
OpenPOWER on IntegriCloud