1; RUN: opt -S -jump-threading -dce < %s | FileCheck %s
2target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
3target triple = "x86_64-apple-darwin10.4"
4
5%"struct.llvm::PATypeHolder" = type { %"struct.llvm::Type"* }
6%"struct.llvm::PointerIntPair<llvm::Use**,2u,llvm::Use::PrevPtrTag,llvm::PointerLikeTypeTraits<llvm::Use**> >" = type { i64 }
7%"struct.llvm::Type" = type opaque
8%"struct.llvm::Use" = type { %"struct.llvm::Value"*, %"struct.llvm::Use"*, %"struct.llvm::PointerIntPair<llvm::Use**,2u,llvm::Use::PrevPtrTag,llvm::PointerLikeTypeTraits<llvm::Use**> >" }
9%"struct.llvm::Value" = type { i32 (...)**, i8, i8, i16, %"struct.llvm::PATypeHolder", %"struct.llvm::Use"*, %"struct.llvm::ValueName"* }
10%"struct.llvm::ValueName" = type opaque
11
12@_ZZN4llvm4castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_E8__func__ = internal constant [5 x i8] c"cast\00", align 8 ; <[5 x i8]*> [#uses=1]
13@.str = private constant [31 x i8] c"include/llvm/Support/Casting.h\00", align 8 ; <[31 x i8]*> [#uses=1]
14@.str1 = private constant [59 x i8] c"isa<X>(Val) && \22cast<Ty>() argument of incompatible type!\22\00", align 8 ; <[59 x i8]*> [#uses=1]
15
16; CHECK: Z3fooPN4llvm5ValueE
17define zeroext i8 @_Z3fooPN4llvm5ValueE(%"struct.llvm::Value"* %V) ssp {
18entry:
19  %0 = getelementptr inbounds %"struct.llvm::Value"* %V, i64 0, i32 1 ; <i8*> [#uses=1]
20  %1 = load i8* %0, align 8                       ; <i8> [#uses=2]
21  %2 = icmp ugt i8 %1, 20                         ; <i1> [#uses=1]
22  br i1 %2, label %bb.i, label %bb2
23
24bb.i:                                             ; preds = %entry
25  %toBoolnot.i.i = icmp ult i8 %1, 21             ; <i1> [#uses=1]
26  br i1 %toBoolnot.i.i, label %bb6.i.i, label %_ZN4llvm8dyn_castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit
27
28; CHECK-NOT: assert
29bb6.i.i:                                          ; preds = %bb.i
30  tail call void @__assert_rtn(i8* getelementptr inbounds ([5 x i8]* @_ZZN4llvm4castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_E8__func__, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8]* @.str, i64 0, i64 0), i32 202, i8* getelementptr inbounds ([59 x i8]* @.str1, i64 0, i64 0)) noreturn
31  unreachable
32
33_ZN4llvm8dyn_castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit: ; preds = %bb.i
34; CHECK-NOT: null
35  %3 = icmp eq %"struct.llvm::Value"* %V, null    ; <i1> [#uses=1]
36  br i1 %3, label %bb2, label %bb
37
38bb:                                               ; preds = %_ZN4llvm8dyn_castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit
39  tail call void @_ZNK4llvm5Value4dumpEv(%"struct.llvm::Value"* %V)
40; CHECK: ret
41  ret i8 1
42
43bb2:                                              ; preds = %entry, %_ZN4llvm8dyn_castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit
44  ret i8 0
45}
46
47declare void @__assert_rtn(i8*, i8*, i32, i8*) noreturn
48
49declare void @_ZNK4llvm5Value4dumpEv(%"struct.llvm::Value"*)
50