1 ; RUN: llvm-reduce --abort-on-invalid-reduction %s -o %t --delta-passes=operands-to-args --test FileCheck --test-arg %s --test-arg --check-prefix=INTERESTING --test-arg --input-file
2 ; RUN: FileCheck -check-prefix=RESULT %s < %t
4 ; Make sure an invalid reduction isn't hit from only replacing one of
5 ; the values when a predecessor is listed multiple times in a phi.
8 ; RESULT: define void @fn(i1 %cmp11, i8 %p.2, i8 %k.2, i8 %p.4, i8 %k.0, i8 %k.4, i8 %p.0, i1 %tobool30, i8 %spec.select, i8 %spec.select1)
11 ; RESULT-NEXT: %p.01 = phi i8 [ 0, %entry ], [ %p.2, %for.inc ]
12 ; RESULT-NEXT: %k.02 = phi i8 [ 0, %entry ], [ %k.2, %for.inc ]
15 ; RESULT-NEXT: %p.1 = phi i8 [ %p.4, %for.cond35 ], [ %k.0, %if.end ]
16 ; RESULT-NEXT: %k.1 = phi i8 [ %k.4, %for.cond35 ], [ 0, %if.end ]
19 ; RESULT-NEXT: %p.26 = phi i8 [ %spec.select, %if.end26 ], [ poison, %if.then13 ], [ %spec.select, %if.end26 ]
20 ; RESULT-NEXT: %k.27 = phi i8 [ %spec.select1, %if.end26 ], [ 0, %if.then13 ], [ %spec.select1, %if.end26 ]
24 ; RESULT-NEXT: %p.48 = phi i8 [ 0, %if.then ], [ %k.0, %if.then13 ]
25 ; RESULT-NEXT: %k.49 = phi i8 [ %k.0, %if.then ], [ 0, %if.then13 ]
27 define void @fn(i1 %cmp11) {
31 for.cond: ; preds = %for.inc, %entry
32 %p.0 = phi i8 [ 0, %entry ], [ %p.2, %for.inc ]
33 %k.0 = phi i8 [ 0, %entry ], [ %k.2, %for.inc ]
34 br i1 %cmp11, label %if.then, label %if.end
36 if.then: ; preds = %for.cond
39 if.end: ; preds = %for.cond
40 br i1 %cmp11, label %if.then13, label %if.end26
42 if.then13: ; preds = %if.end
43 br i1 %cmp11, label %for.inc, label %for.cond35
45 if.end26: ; preds = %for.cond35, %if.end
46 ; INTERESTING: %p.1 = phi i8
47 ; INTERESTING: %k.1 = phi i8
49 %p.1 = phi i8 [ %p.4, %for.cond35 ], [ %k.0, %if.end ]
50 %k.1 = phi i8 [ %k.4, %for.cond35 ], [ 0, %if.end ]
51 %tobool30 = icmp ne i8 %p.0, 0
52 %spec.select = select i1 false, i8 0, i8 %p.1
53 %spec.select1 = select i1 %tobool30, i8 %k.1, i8 0
54 br i1 false, label %for.inc, label %for.inc
56 ; INTERESTING: {{^}}for.inc:
58 ; INTERESTING-SAME: [ %spec.select{{[0-9]*}}, %if.end26 ]
61 ; INTERESTING-SAME: [ %spec.select{{[0-9]*}}, %if.end26 ]
62 for.inc: ; preds = %if.end26, %if.end26, %if.then13
63 %p.2 = phi i8 [ %spec.select, %if.end26 ], [ poison, %if.then13 ], [ %spec.select, %if.end26 ]
64 %k.2 = phi i8 [ %spec.select1, %if.end26 ], [ 0, %if.then13 ], [ %spec.select1, %if.end26 ]
65 %0 = load i32, ptr null, align 4
68 for.cond35: ; preds = %if.then13, %if.then
69 %p.4 = phi i8 [ 0, %if.then ], [ %k.0, %if.then13 ]
70 %k.4 = phi i8 [ %k.0, %if.then ], [ 0, %if.then13 ]
71 %tobool36 = icmp eq i32 0, 0