[PATCH] D75814: [InstCombine] Don't simplify calls without uses

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 9 11:19:57 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3ca6876ed0c: [InstCombine] Don't simplify calls without uses (authored by nikic).
Herald added a subscriber: hiraditya.

Changed prior to commit:
  https://reviews.llvm.org/D75814?vs=248953&id=249169#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75814

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/Transforms/InstCombine/pr44245.ll


Index: llvm/test/Transforms/InstCombine/pr44245.ll
===================================================================
--- llvm/test/Transforms/InstCombine/pr44245.ll
+++ llvm/test/Transforms/InstCombine/pr44245.ll
@@ -59,7 +59,7 @@
 ; CHECK-NEXT:    br label [[BB47]]
 ; CHECK:       bb152:
 ; CHECK-NEXT:    [[TMP1848]] = load i8*, i8** inttoptr (i64 16 to i8**), align 16
-; CHECK-NEXT:    call void undef()
+; CHECK-NEXT:    store i1 true, i1* undef, align 1
 ; CHECK-NEXT:    br label [[BB150]]
 ;
 bb16:                                             ; preds = %bb
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1787,8 +1787,11 @@
 /// instructions. For normal calls, it allows visitCallBase to do the heavy
 /// lifting.
 Instruction *InstCombiner::visitCallInst(CallInst &CI) {
-  if (Value *V = SimplifyCall(&CI, SQ.getWithInstruction(&CI)))
-    return replaceInstUsesWith(CI, V);
+  // Don't try to simplify calls without uses. It will not do anything useful,
+  // but will result in the following folds being skipped.
+  if (!CI.use_empty())
+    if (Value *V = SimplifyCall(&CI, SQ.getWithInstruction(&CI)))
+      return replaceInstUsesWith(CI, V);
 
   if (isFreeCall(&CI, &TLI))
     return visitFree(CI);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75814.249169.patch
Type: text/x-patch
Size: 1419 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200309/c59991e7/attachment.bin>


More information about the llvm-commits mailing list