1 ; NOTE: Assertions have been autogenerated by update_test_checks.py
2 ; RUN: opt -instsimplify -S < %s 2>&1 -pass-remarks-analysis=.* | FileCheck %s
4 ; Verify that warnings are emitted for the 2nd and 3rd tests.
6 ; CHECK: remark: /tmp/s.c:1:13: Detected conflicting code assumptions.
7 ; CHECK: remark: /tmp/s.c:4:10: Detected conflicting code assumptions.
10 ; CHECK-LABEL: @test1(
13 call void @llvm.assume(i1 1)
18 ; The alloca guarantees that the low bits of %a are zero because of alignment.
19 ; The assume says the opposite. The assume is processed last, so that's the
20 ; return value. There's no way to win (we can't undo transforms that happened
21 ; based on half-truths), so just don't crash.
23 define i64 @PR31809() !dbg !7 {
24 ; CHECK-LABEL: @PR31809(
25 ; CHECK-NEXT: ret i64 3
28 %t1 = ptrtoint i32* %a to i64, !dbg !9
29 %cond = icmp eq i64 %t1, 3
30 call void @llvm.assume(i1 %cond)
34 ; Similar to above: there's no way to know which assumption is truthful,
35 ; so just don't crash. The second icmp+assume gets processed later, so that
36 ; determines the return value.
38 define i8 @conflicting_assumptions(i8 %x) !dbg !10 {
39 ; CHECK-LABEL: @conflicting_assumptions(
40 ; CHECK-NEXT: call void @llvm.assume(i1 false)
41 ; CHECK-NEXT: [[COND2:%.*]] = icmp eq i8 %x, 4
42 ; CHECK-NEXT: call void @llvm.assume(i1 [[COND2]])
43 ; CHECK-NEXT: ret i8 5
45 %add = add i8 %x, 1, !dbg !11
46 %cond1 = icmp eq i8 %x, 3
47 call void @llvm.assume(i1 %cond1)
48 %cond2 = icmp eq i8 %x, 4
49 call void @llvm.assume(i1 %cond2)
53 declare void @llvm.assume(i1) nounwind
56 !llvm.module.flags = !{!3, !4, !5}
59 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 282540) (llvm/trunk 282542)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
60 !1 = !DIFile(filename: "/tmp/s.c", directory: "/tmp")
62 !3 = !{i32 2, !"Dwarf Version", i32 4}
63 !4 = !{i32 2, !"Debug Info Version", i32 3}
64 !5 = !{i32 1, !"PIC Level", i32 2}
65 !6 = !{!"clang version 4.0.0 (trunk 282540) (llvm/trunk 282542)"}
66 !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, variables: !2)
67 !8 = !DISubroutineType(types: !2)
68 !9 = !DILocation(line: 1, column: 13, scope: !7)
69 !10 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !0, variables: !2)
70 !11 = !DILocation(line: 4, column: 10, scope: !10)
71 !12 = !DILocation(line: 4, column: 3, scope: !10)