1 ; RUN: opt -S -passes=licm -o - %s | FileCheck %s
3 ; Be sure that we don't hoist loads incorrectly if a loop has conditional UB.
6 declare void @check(i8)
7 declare void @llvm.memcpy.p0.p0.i64(ptr, ptr, i64, i32, i1)
9 ; CHECK-LABEL: define void @buggy
10 define void @buggy(ptr %src, ptr %kOne) {
12 %dst = alloca [1 x i8], align 1
13 store i8 42, ptr %dst, align 1
14 %srcval = load i16, ptr %src
17 while.cond: ; preds = %if.end, %entry
18 %dp.0 = phi ptr [ %dst, %entry ], [ %dp.1, %if.end ]
19 %0 = load volatile i1, ptr %kOne, align 4
20 br i1 %0, label %if.else, label %if.then
22 if.then: ; preds = %while.cond
23 store i8 9, ptr %dp.0, align 1
26 if.else: ; preds = %while.cond
27 call void @llvm.memcpy.p0.p0.i64(ptr %dp.0, ptr %src, i64 2, i32 1, i1 false)
28 %dp.new = getelementptr inbounds i8, ptr %dp.0, i64 1
31 if.end: ; preds = %if.else, %if.then
32 %dp.1 = phi ptr [ %dp.0, %if.then ], [ %dp.new, %if.else ]
33 ; CHECK: %1 = load i8, ptr %dst
34 %1 = load i8, ptr %dst, align 1
35 ; CHECK-NEXT: call void @check(i8 %1)
36 call void @check(i8 %1)