[llvm-branch-commits] [llvm-branch] r115855 - in /llvm/branches/ggreif/switch-opts: lib/Transforms/Scalar/CodeGenPrepare.cpp test/CodeGen/X86/switch-and.ll

Gabor Greif ggreif at gmail.com
Wed Oct 6 15:12:45 PDT 2010


Author: ggreif
Date: Wed Oct  6 17:12:45 2010
New Revision: 115855

URL: http://llvm.org/viewvc/llvm-project?rev=115855&view=rev
Log:
finally eliminate the switch

Modified:
    llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp
    llvm/branches/ggreif/switch-opts/test/CodeGen/X86/switch-and.ll

Modified: llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=115855&r1=115854&r2=115855&view=diff
==============================================================================
--- llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp Wed Oct  6 17:12:45 2010
@@ -947,10 +947,12 @@
             ConstantInt *Bot(cast<ConstantInt>(ConstantInt::get(Ty, Bottom)));
             if (unsigned BottomLeg = I->findCaseValue(Bot)) {
               // Replace nz.bottom BB with found leg.
+              New3->replaceAllUsesWith(I->getSuccessor(BottomLeg));
             } else {
               // Otherwise with default leg.
-              assert(0);
+              New3->replaceAllUsesWith(I->getDefaultDest());
             }
+            New3->eraseFromParent();
           }
         }
         return true;

Modified: llvm/branches/ggreif/switch-opts/test/CodeGen/X86/switch-and.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/switch-opts/test/CodeGen/X86/switch-and.ll?rev=115855&r1=115854&r2=115855&view=diff
==============================================================================
--- llvm/branches/ggreif/switch-opts/test/CodeGen/X86/switch-and.ll (original)
+++ llvm/branches/ggreif/switch-opts/test/CodeGen/X86/switch-and.ll Wed Oct  6 17:12:45 2010
@@ -27,15 +27,11 @@
 
 ;; CHECK: nz.non-middle:
 ;; CHECK-NEXT: %"top?" = icmp ugt i32 %conv, 2
-;; CHECK-NEXT: br i1 %"top?", label %sw.bb6, label %nz.bottom
+;; CHECK-NEXT: br i1 %"top?", label %sw.bb6, label %sw.bb
 
-;; CHECK: nz.bottom:
-;; CHECK-NEXT: switch i32 %conv, label %sw.epilog
-;; CHECK-NEXT: i32 1, label %sw.bb
    i32 1, label %sw.bb
    i32 3, label %sw.bb6
    i32 2, label %sw.bb8
-;; CHECK-NEXT: ]
  ]
 
 sw.bb:                                            ; preds = %tailrecurse
@@ -56,6 +52,8 @@
  %add.ptr11 = getelementptr inbounds %struct.Foo* %this, i64 %this.tr.sum
  ret %struct.Foo* %add.ptr11
 
+;; CHECK: sw.epilog: ; No predecessors!
+
 sw.epilog:                                        ; preds = %tailrecurse
  ret %struct.Foo* undef
 }





More information about the llvm-branch-commits mailing list