[PATCH] D36012: Update phi nodes in LowerTypeTests control flow simplification

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 13:43:53 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL309621: Update phi nodes in LowerTypeTests control flow simplification (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D36012?vs=108701&id=108993#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36012

Files:
  llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/trunk/test/Transforms/LowerTypeTests/simplify_phi.ll


Index: llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
+++ llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -634,6 +634,10 @@
                            Br->getMetadata(LLVMContext::MD_prof));
         ReplaceInstWithInst(InitialBB->getTerminator(), NewBr);
 
+        // Update phis in Else resulting from InitialBB being split
+        for (auto &Phi : Else->phis())
+          Phi.addIncoming(Phi.getIncomingValueForBlock(Then), InitialBB);
+
         IRBuilder<> ThenB(CI);
         return createBitSetTest(ThenB, TIL, BitOffset);
       }
Index: llvm/trunk/test/Transforms/LowerTypeTests/simplify_phi.ll
===================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/simplify_phi.ll
+++ llvm/trunk/test/Transforms/LowerTypeTests/simplify_phi.ll
@@ -0,0 +1,20 @@
+; Ensure that LowerTypeTests control flow simplification correctly handle phi nodes.
+; RUN: opt -S -lowertypetests -lowertypetests-summary-action=import -lowertypetests-read-summary=%S/Inputs/import.yaml < %s | FileCheck %s
+
+target datalayout = "e-p:64:64"
+
+declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone
+
+; CHECK: define i1 @bytearray7(i8* [[p:%.*]])
+define i1 @bytearray7(i8* %p) {
+  %x = call i1 @llvm.type.test(i8* %p, metadata !"bytearray7")
+  br i1 %x, label %t, label %f
+
+t:
+  br label %f
+
+f:
+  ; CHECK: %test = phi i1 [ false, %{{[0-9]+}} ], [ true, %t ], [ false, %0 ]
+  %test = phi i1 [ false, %0 ], [ true, %t ]
+  ret i1 %test
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36012.108993.patch
Type: text/x-patch
Size: 1630 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170731/664bea27/attachment.bin>


More information about the llvm-commits mailing list