llvm.org GIT mirror llvm / 1e45265
Make jump threading honor x|undef -> true and x&undef -> false, instead of considering x|undef -> x, which may not be true. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95850 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 9 years ago
2 changed file(s) with 77 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
335335 else
336336 InterestingVal = ConstantInt::getFalse(I->getContext());
337337
338 // Scan for the sentinel.
338 // Scan for the sentinel. If we find an undef, force it to the
339 // interesting value: x|undef -> true and x&undef -> false.
339340 for (unsigned i = 0, e = LHSVals.size(); i != e; ++i)
340 if (LHSVals[i].first == InterestingVal || LHSVals[i].first == 0)
341 if (LHSVals[i].first == InterestingVal || LHSVals[i].first == 0) {
341342 Result.push_back(LHSVals[i]);
343 Result.back().first = InterestingVal;
344 }
342345 for (unsigned i = 0, e = RHSVals.size(); i != e; ++i)
343 if (RHSVals[i].first == InterestingVal || RHSVals[i].first == 0)
346 if (RHSVals[i].first == InterestingVal || RHSVals[i].first == 0) {
344347 Result.push_back(RHSVals[i]);
348 Result.back().first = InterestingVal;
349 }
345350 return !Result.empty();
346351 }
347352
0 ; RUN: opt -jump-threading -S %s | FileCheck %s
1 ; rdar://7620633
2
3 target 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"
4 target triple = "x86_64-apple-darwin11.0"
5
6 define void @test1(i8* %args, i32 %from_tty) nounwind optsize ssp {
7 entry:
8 %tmp = call i8* @f3(void (i8*)* null, i8* null) nounwind ; [#uses=1]
9 %tmp1 = icmp eq i8* %args, null ; [#uses=1]
10 br i1 %tmp1, label %bb2, label %bb
11
12 ; CHECK: entry:
13 ; CHECK-NEXT: %tmp = call i8* @f3
14 ; CHECK-NEXT: %tmp1 = icmp eq i8* %args, null
15 ; CHECK-NEXT: br i1 %tmp1, label %bb7, label %bb
16
17 bb: ; preds = %entry
18 %tmp2 = call noalias i8** @buildargv(i8* %args) nounwind ; [#uses=4]
19 %tmp3 = icmp eq i8** %tmp2, null ; [#uses=1]
20 br i1 %tmp3, label %bb2, label %bb1
21
22 bb1: ; preds = %bb
23 call void @f2(i8** %tmp2) nounwind
24 br label %bb2
25
26 bb2: ; preds = %bb1, %bb, %entry
27 %argv.0 = phi i8** [ %tmp2, %bb1 ], [ %tmp2, %bb ], [ undef, %entry ] ; [#uses=4]
28 %tmp5 = icmp eq i8* %args, null ; [#uses=1]
29 %tmp6 = icmp eq i8** %argv.0, null ; [#uses=1]
30 %tmp7 = or i1 %tmp5, %tmp6 ; [#uses=1]
31 br i1 %tmp7, label %bb7, label %bb5
32
33 bb5: ; preds = %bb2
34 %tmp8 = load i8** %argv.0, align 8 ; [#uses=1]
35 %tmp9 = icmp eq i8* %tmp8, null ; [#uses=1]
36 br i1 %tmp9, label %bb7, label %bb6
37
38 bb6: ; preds = %bb5
39 %tmp10 = load i8** %argv.0, align 8 ; [#uses=1]
40 %tmp11 = load i8* %tmp10, align 1 ; [#uses=1]
41 %tmp12 = icmp eq i8 %tmp11, 0 ; [#uses=1]
42 br i1 %tmp12, label %bb7, label %bb8
43
44 bb7: ; preds = %bb6, %bb5, %bb2
45 call void @f1() nounwind optsize ssp
46 br label %bb9
47
48 bb8: ; preds = %bb6
49 %tmp13 = load i8** %argv.0, align 8 ; [#uses=1]
50 %tmp14 = call i64 @f5(i8* %tmp13) nounwind ; [#uses=0]
51 br label %bb9
52
53 bb9: ; preds = %bb8, %bb7
54 call void @f4(i8* %tmp) nounwind
55 ret void
56 }
57
58 declare noalias i8** @buildargv(i8*)
59
60 declare void @f2(i8**)
61
62 declare void @f4(i8*)
63
64 declare i8* @f3(void (i8*)*, i8*)
65
66 declare void @f1()
67
68 declare i64 @f5(i8*)