blob: 4255238126b80bbee05fb533b823bee17a2da07b [file] [log] [blame]
Sanjay Patel69632442016-03-25 20:12:25 +00001; NOTE: Assertions have been autogenerated by update_test_checks.py
Hal Finkel93046912014-07-25 21:13:35 +00002; RUN: opt -instsimplify -S < %s | FileCheck %s
3
4define void @test1() {
Sanjay Patel69632442016-03-25 20:12:25 +00005; CHECK-LABEL: @test1(
6; CHECK: ret void
7;
Hal Finkel93046912014-07-25 21:13:35 +00008 call void @llvm.assume(i1 1)
9 ret void
10
Hal Finkel93046912014-07-25 21:13:35 +000011}
12
Sanjay Patel25f6d712017-02-01 15:41:32 +000013; The alloca guarantees that the low bits of %a are zero because of alignment.
14; The assume says the opposite. The assume is processed last, so that's the
15; return value. There's no way to win (we can't undo transforms that happened
16; based on half-truths), so just don't crash.
17
18define i64 @PR31809() {
19; CHECK-LABEL: @PR31809(
20; CHECK-NEXT: ret i64 3
21;
22 %a = alloca i32
23 %t1 = ptrtoint i32* %a to i64
24 %cond = icmp eq i64 %t1, 3
25 call void @llvm.assume(i1 %cond)
26 ret i64 %t1
27}
28
29; Similar to above: there's no way to know which assumption is truthful,
30; so just don't crash. The second icmp+assume gets processed later, so that
Sanjay Patel52e4e652017-02-01 22:27:34 +000031; determines the return value.
Sanjay Patel25f6d712017-02-01 15:41:32 +000032
33define i8 @conflicting_assumptions(i8 %x) {
34; CHECK-LABEL: @conflicting_assumptions(
35; CHECK-NEXT: call void @llvm.assume(i1 false)
36; CHECK-NEXT: [[COND2:%.*]] = icmp eq i8 %x, 4
37; CHECK-NEXT: call void @llvm.assume(i1 [[COND2]])
38; CHECK-NEXT: ret i8 5
39;
40 %add = add i8 %x, 1
41 %cond1 = icmp eq i8 %x, 3
42 call void @llvm.assume(i1 %cond1)
43 %cond2 = icmp eq i8 %x, 4
44 call void @llvm.assume(i1 %cond2)
45 ret i8 %add
46}
47
Hal Finkel93046912014-07-25 21:13:35 +000048declare void @llvm.assume(i1) nounwind
49