1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=licm %s | FileCheck %s --check-prefix=NO_ASSUME
3 ; RUN: opt -S -passes=licm --enable-knowledge-retention %s | FileCheck %s --check-prefix=USE_ASSUME
4 ; ModuleID = '../pr23608.ll'
5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-unknown-linux-gnu"
8 %struct.PyFrameObject = type { i32 }
10 @a = common global ptr null, align 8
11 @__msan_origin_tls = external thread_local(initialexec) global i32
14 ; NO_ASSUME-LABEL: @fn1(
15 ; NO_ASSUME-NEXT: entry:
16 ; NO_ASSUME-NEXT: br label [[INDIRECTGOTO:%.*]]
17 ; NO_ASSUME: while.cond:
18 ; NO_ASSUME-NEXT: [[TMP:%.*]] = load ptr, ptr @a, align 8
19 ; NO_ASSUME-NEXT: br label [[BB2:%.*]]
21 ; NO_ASSUME-NEXT: call void @__msan_warning_noreturn()
22 ; NO_ASSUME-NEXT: unreachable
24 ; NO_ASSUME-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[TMP]] to i64
25 ; NO_ASSUME-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[TMP4]], 0
26 ; NO_ASSUME-NEXT: br i1 [[TOBOOL]], label [[BB13:%.*]], label [[BB15:%.*]]
28 ; NO_ASSUME-NEXT: [[TMP4_LCSSA:%.*]] = phi i64 [ [[TMP4]], [[BB2]] ]
29 ; NO_ASSUME-NEXT: [[TMP8_LE:%.*]] = inttoptr i64 [[TMP4_LCSSA]] to ptr
30 ; NO_ASSUME-NEXT: call void @__msan_warning_noreturn()
31 ; NO_ASSUME-NEXT: unreachable
33 ; NO_ASSUME-NEXT: br i1 [[TOBOOL]], label [[WHILE_END:%.*]], label [[WHILE_COND:%.*]]
34 ; NO_ASSUME: while.end:
35 ; NO_ASSUME-NEXT: ret void
36 ; NO_ASSUME: indirectgoto:
37 ; NO_ASSUME-NEXT: indirectbr ptr null, [label [[INDIRECTGOTO]], label %while.cond]
39 ; USE_ASSUME-LABEL: @fn1(
40 ; USE_ASSUME-NEXT: entry:
41 ; USE_ASSUME-NEXT: br label [[INDIRECTGOTO:%.*]]
42 ; USE_ASSUME: while.cond:
43 ; USE_ASSUME-NEXT: [[TMP:%.*]] = load ptr, ptr @a, align 8
44 ; USE_ASSUME-NEXT: br label [[BB2:%.*]]
46 ; USE_ASSUME-NEXT: call void @__msan_warning_noreturn()
47 ; USE_ASSUME-NEXT: unreachable
49 ; USE_ASSUME-NEXT: call void @llvm.assume(i1 true) [ "dereferenceable"(ptr [[TMP]], i64 4), "nonnull"(ptr [[TMP]]), "align"(ptr [[TMP]], i64 4) ]
50 ; USE_ASSUME-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[TMP]] to i64
51 ; USE_ASSUME-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[TMP4]], 0
52 ; USE_ASSUME-NEXT: br i1 [[TOBOOL]], label [[BB13:%.*]], label [[BB15:%.*]]
54 ; USE_ASSUME-NEXT: [[TMP4_LCSSA:%.*]] = phi i64 [ [[TMP4]], [[BB2]] ]
55 ; USE_ASSUME-NEXT: [[TMP8_LE:%.*]] = inttoptr i64 [[TMP4_LCSSA]] to ptr
56 ; USE_ASSUME-NEXT: call void @__msan_warning_noreturn()
57 ; USE_ASSUME-NEXT: unreachable
59 ; USE_ASSUME-NEXT: br i1 [[TOBOOL]], label [[WHILE_END:%.*]], label [[WHILE_COND:%.*]]
60 ; USE_ASSUME: while.end:
61 ; USE_ASSUME-NEXT: ret void
62 ; USE_ASSUME: indirectgoto:
63 ; USE_ASSUME-NEXT: indirectbr ptr null, [label [[INDIRECTGOTO]], label %while.cond]
66 br label %indirectgoto
68 while.cond: ; preds = %indirectgoto, %bb15
69 %tmp = load ptr, ptr @a, align 8
70 %and = and i64 ptrtoint (ptr @a to i64), -70368744177665
71 %itop = inttoptr i64 %and to ptr
72 %_msld = load i64, ptr %itop, align 8
73 %add = add i64 %and, 35184372088832
74 %itop2 = inttoptr i64 %add to ptr
75 %tmp1 = load i32, ptr %itop2, align 8
78 bb: ; preds = %while.cond
79 call void @__msan_warning_noreturn()
82 bb2: ; preds = %while.cond
83 %tmp3 = load i32, ptr %tmp, align 4
84 %tmp4 = ptrtoint ptr %tmp to i64
85 %tmp8 = inttoptr i64 %tmp4 to ptr
86 %tobool = icmp eq i64 %tmp4, 0
87 br i1 %tobool, label %bb13, label %bb15
90 %.lcssa7 = phi ptr [ %tmp8, %bb2 ]
91 call void @__msan_warning_noreturn()
95 br i1 %tobool, label %while.end, label %while.cond
97 while.end: ; preds = %bb15
100 indirectgoto: ; preds = %indirectgoto, %entry
101 indirectbr ptr null, [label %indirectgoto, label %while.cond]
104 declare void @__msan_warning_noreturn()