Fix a really bad miscompile introduced in r216865 - the else-if logic
[oota-llvm.git] / test / Transforms / LoopUnswitch / preserve-analyses.ll
index 1a0e9e6c879f6ef9d633f97dcc6053ce25d45218..f79612bef51e611621650cc2042a472a0d22a785 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -loop-unswitch %s -disable-output
+; RUN: opt -loop-unswitch -verify-loop-info -verify-dom-info -disable-output < %s
 
 ; Loop unswitch should be able to unswitch these loops and
 ; preserve LCSSA and LoopSimplify forms.
@@ -9,7 +9,7 @@ target triple = "armv6-apple-darwin9"
 @delim1 = external global i32                     ; <i32*> [#uses=1]
 @delim2 = external global i32                     ; <i32*> [#uses=1]
 
-define arm_apcscc i32 @ineqn(i8* %s, i8* %p) nounwind readonly {
+define i32 @ineqn(i8* %s, i8* %p) nounwind readonly {
 entry:
   %0 = load i32* @delim1, align 4                 ; <i32> [#uses=1]
   %1 = load i32* @delim2, align 4                 ; <i32> [#uses=1]
@@ -93,3 +93,37 @@ bb6:                                              ; preds = %bb2
 return:                                             ; preds = %bb8, %bb
   ret void
 }
+
+; This function requires special handling to preserve LCSSA form.
+; PR4934
+
+define void @pnp_check_irq() nounwind noredzone {
+entry:
+  %conv56 = trunc i64 undef to i32                ; <i32> [#uses=1]
+  br label %while.cond.i
+
+while.cond.i:                                     ; preds = %while.cond.i.backedge, %entry
+  %call.i25 = call i8* @pci_get_device() nounwind noredzone ; <i8*> [#uses=2]
+  br i1 undef, label %if.then65, label %while.body.i
+
+while.body.i:                                     ; preds = %while.cond.i
+  br i1 undef, label %if.then31.i.i, label %while.cond.i.backedge
+
+while.cond.i.backedge:                            ; preds = %if.then31.i.i, %while.body.i
+  br label %while.cond.i
+
+if.then31.i.i:                                    ; preds = %while.body.i
+  switch i32 %conv56, label %while.cond.i.backedge [
+    i32 14, label %if.then42.i.i
+    i32 15, label %if.then42.i.i
+  ]
+
+if.then42.i.i:                                    ; preds = %if.then31.i.i, %if.then31.i.i
+  %call.i25.lcssa48 = phi i8* [ %call.i25, %if.then31.i.i ], [ %call.i25, %if.then31.i.i ] ; <i8*> [#uses=0]
+  unreachable
+
+if.then65:                                        ; preds = %while.cond.i
+  unreachable
+}
+
+declare i8* @pci_get_device() noredzone