[PATCH] D61695: [InstCombine] When turning sext into zext due to known bits, return the new ZExt instead of calling replaceinstuseswith

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 13:57:09 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL360284: [InstCombine] When turning sext into zext due to known bits, return the new… (authored by ctopper, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61695?vs=198715&id=198723#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61695/new/

https://reviews.llvm.org/D61695

Files:
  llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp


Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1372,10 +1372,8 @@
   // 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)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61695.198723.patch
Type: text/x-patch
Size: 806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190508/d0d6ddb9/attachment.bin>


More information about the llvm-commits mailing list