156 lines · plain
1; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=simplify-conditionals-true --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS,CHECK --test-arg %s --test-arg --input-file %s -o %t2; RUN: FileCheck --check-prefixes=RESULT-TRUE,RESULT,CHECK %s < %t3 4; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=simplify-conditionals-false --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS,CHECK --test-arg %s --test-arg --input-file %s -o %t5; RUN: FileCheck --check-prefixes=RESULT-FALSE,RESULT,CHECK %s < %t6 7; Make sure there is no unreachable code introduced by the reduction8 9; CHECK-LABEL: @func_simplifies_true(10; CHECK-INTERESTINGNESS: store i32 1,11 12; RESULT-TRUE: bb0:13; RESULT-TRUE: store i32 0, ptr null, align 414; RESULT-TRUE-NEXT: store i32 1, ptr null, align 415; RESULT-TRUE-NEXT: br label %bb216; RESULT-TRUE-NOT: bb117 18; RESULT-FALSE: bb0:19; RESULT-FALSE-NEXT: store i32 0, ptr null, align 420; RESULT-FALSE-NEXT: br i1 %cond0, label %bb1, label %bb221 22; RESULT-FALSE: bb1: ; preds = %bb023; RESULT-FALSE-NEXT: store i32 1, ptr null, align 424; RESULT-FALSE-NEXT: br label %bb325 26; RESULT-FALSE: bb2: ; preds = %bb027; RESULT-FALSE-NEXT: store i32 2, ptr null, align 428; RESULT-FALSE-NEXT: br label %bb329 30; RESULT-FALSE: bb3: ; preds = %bb1, %bb231; RESULT-FALSE-NEXT: ret void32define void @func_simplifies_true(i1 %cond0, i1 %cond1) {33bb0:34 store i32 0, ptr null35 br i1 %cond0, label %bb1, label %bb236 37bb1:38 store i32 1, ptr null39 br i1 %cond1, label %bb2, label %bb340 41bb2:42 store i32 2, ptr null43 br label %bb344 45bb3:46 ret void47}48 49; CHECK-LABEL: @func_simplifies_false(50; CHECK-INTERESTINGNESS: store i32 0,51 52; RESULT-TRUE: bb0:53; RESULT-TRUE: store i32 0, ptr null, align 454; RESULT-TRUE-NEXT: store i32 1, ptr null, align 455; RESULT-TRUE-NEXT: br label %bb256; RESULT-TRUE-NOT: bb157 58 59; RESULT-FALSE: bb0:60; RESULT-FALSE: store i32 0, ptr null, align 461; RESULT-FALSE-NEXT: br label %bb262 63; RESULT-FALSE: bb2: ; preds = %bb064; RESULT-FALSE-NEXT: store i32 2, ptr null, align 465; RESULT-FALSE-NEXT: br label %bb366 67; RESULT-FALSE: bb3: ; preds = %bb268; RESULT-FALSE-NEXT: ret void69define void @func_simplifies_false(i1 %cond0, i1 %cond1) {70bb0:71 store i32 0, ptr null72 br i1 %cond0, label %bb1, label %bb273 74bb1:75 store i32 1, ptr null76 br i1 %cond1, label %bb2, label %bb377 78bb2:79 store i32 2, ptr null80 br label %bb381 82bb3:83 ret void84}85 86; Make sure we don't break the reduction in the other functions by87; having something interesting in unrelated unreachable code.88 89; CHECK-LABEL: @func_simplifies_true_with_interesting_unreachable_code(90; CHECK-INTERESTINGNESS: store i32 0,91; CHECK-INTERESTINGNESS: store i32 %arg,92 93 94; RESULT: bb0:95; RESULT-NEXT: store i32 096; RESULT-NEXT: br i1 %cond0, label %bb1, label %bb297 98; RESULT: bb1:99; RESULT-NEXT: store i32 1100; RESULT-NEXT: br i1 %cond1, label %bb2, label %bb3101 102; RESULT: bb2:103; RESULT-NEXT: store i32 2104; RESULT-NEXT: br label %bb3105 106; RESULT: dead_code: ; preds = %dead_code107; RESULT-NEXT: store i32 %arg,108; RESULT-NEXT: br label %dead_code109define void @func_simplifies_true_with_interesting_unreachable_code(i1 %cond0, i1 %cond1, i32 %arg) {110bb0:111 store i32 0, ptr null112 br i1 %cond0, label %bb1, label %bb2113 114bb1:115 store i32 1, ptr null116 br i1 %cond1, label %bb2, label %bb3117 118bb2:119 store i32 2, ptr null120 br label %bb3121 122bb3:123 ret void124 125dead_code:126 store i32 %arg, ptr null127 br label %dead_code128}129 130@block_address_user = constant [1 x ptr] [ptr blockaddress(@will_be_unreachable_blockaddress_use, %will_be_unreachable)]131 132; CHECK-LABEL: @will_be_unreachable_blockaddress_use(133; CHECK-INTERESTINGNESS: inttoptr134 135; RESULT-FALSE: entry:136; RESULT-FALSE-NEXT: %i2p = inttoptr i64 %int to ptr137; RESULT-FALSE-NEXT: br label %exit138 139; RESULT-FALSE: exit: ; preds = %entry140; RESULT-FALSE-NEXT: ret i1 false141define i1 @will_be_unreachable_blockaddress_use(i1 %cond, i64 %int) {142entry:143 %i2p = inttoptr i64 %int to ptr144 br i1 %cond, label %will_be_unreachable, label %exit145 146will_be_unreachable:147 %load = load ptr, ptr %i2p, align 8148 br label %for.body149 150for.body:151 br label %for.body152 153exit:154 ret i1 false155}156