1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -jump-threading -S %s -o - | FileCheck %s --check-prefix=DEFAULT 3; RUN: opt -jump-threading -S -jump-threading-threshold=6 %s -o - | FileCheck %s --check-prefix=OVERIDE 4 5@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 6define i32 @test_minsize(i32 %argc, i8** nocapture readonly %argv) local_unnamed_addr #0 { 7; DEFAULT-LABEL: @test_minsize( 8; DEFAULT-NEXT: entry: 9; DEFAULT-NEXT: [[CMP:%.*]] = icmp eq i32 [[ARGC:%.*]], 2 10; DEFAULT-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[COND_END:%.*]] 11; DEFAULT: cond.true: 12; DEFAULT-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8*, i8** [[ARGV:%.*]], i32 1 13; DEFAULT-NEXT: [[TMP0:%.*]] = load i8*, i8** [[ARRAYIDX]], align 4 14; DEFAULT-NEXT: [[CALL:%.*]] = tail call i32 @atoi(i8* [[TMP0]]) 15; DEFAULT-NEXT: br label [[COND_END]] 16; DEFAULT: cond.end: 17; DEFAULT-NEXT: [[COND:%.*]] = phi i32 [ [[CALL]], [[COND_TRUE]] ], [ 46, [[ENTRY:%.*]] ] 18; DEFAULT-NEXT: [[TMP1:%.*]] = mul i32 [[COND]], [[COND]] 19; DEFAULT-NEXT: [[TMP2:%.*]] = mul i32 [[TMP1]], [[TMP1]] 20; DEFAULT-NEXT: [[TMP3:%.*]] = mul i32 [[COND]], [[TMP2]] 21; DEFAULT-NEXT: [[TMP4:%.*]] = icmp sgt i32 [[COND]], 0 22; DEFAULT-NEXT: br i1 [[TMP4]], label [[TMP5:%.*]], label [[TMP6:%.*]] 23; DEFAULT: 5: 24; DEFAULT-NEXT: br label [[TMP6]] 25; DEFAULT: 6: 26; DEFAULT-NEXT: [[TMP7:%.*]] = phi i32 [ [[COND]], [[TMP5]] ], [ 0, [[COND_END]] ] 27; DEFAULT-NEXT: [[TMP8:%.*]] = mul i32 [[TMP3]], [[TMP7]] 28; DEFAULT-NEXT: [[CALL33:%.*]] = tail call i32 (i8*, ...) @printf(i8* nonnull dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 [[TMP8]]) 29; DEFAULT-NEXT: ret i32 0 30; 31; OVERIDE-LABEL: @test_minsize( 32; OVERIDE-NEXT: entry: 33; OVERIDE-NEXT: [[CMP:%.*]] = icmp eq i32 [[ARGC:%.*]], 2 34; OVERIDE-NEXT: br i1 [[CMP]], label [[COND_END:%.*]], label [[COND_END_THREAD:%.*]] 35; OVERIDE: cond.end: 36; OVERIDE-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8*, i8** [[ARGV:%.*]], i32 1 37; OVERIDE-NEXT: [[TMP0:%.*]] = load i8*, i8** [[ARRAYIDX]], align 4 38; OVERIDE-NEXT: [[CALL:%.*]] = tail call i32 @atoi(i8* [[TMP0]]) 39; OVERIDE-NEXT: [[TMP1:%.*]] = mul i32 [[CALL]], [[CALL]] 40; OVERIDE-NEXT: [[TMP2:%.*]] = mul i32 [[TMP1]], [[TMP1]] 41; OVERIDE-NEXT: [[TMP3:%.*]] = mul i32 [[CALL]], [[TMP2]] 42; OVERIDE-NEXT: [[TMP4:%.*]] = icmp sgt i32 [[CALL]], 0 43; OVERIDE-NEXT: br i1 [[TMP4]], label [[COND_END_THREAD]], label [[TMP6:%.*]] 44; OVERIDE: cond.end.thread: 45; OVERIDE-NEXT: [[TMP5:%.*]] = phi i32 [ [[TMP3]], [[COND_END]] ], [ 205962976, [[ENTRY:%.*]] ] 46; OVERIDE-NEXT: [[COND2:%.*]] = phi i32 [ [[CALL]], [[COND_END]] ], [ 46, [[ENTRY]] ] 47; OVERIDE-NEXT: br label [[TMP6]] 48; OVERIDE: 6: 49; OVERIDE-NEXT: [[TMP7:%.*]] = phi i32 [ [[TMP5]], [[COND_END_THREAD]] ], [ [[TMP3]], [[COND_END]] ] 50; OVERIDE-NEXT: [[TMP8:%.*]] = phi i32 [ [[COND2]], [[COND_END_THREAD]] ], [ 0, [[COND_END]] ] 51; OVERIDE-NEXT: [[TMP9:%.*]] = mul i32 [[TMP7]], [[TMP8]] 52; OVERIDE-NEXT: [[CALL33:%.*]] = tail call i32 (i8*, ...) @printf(i8* nonnull dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 [[TMP9]]) 53; OVERIDE-NEXT: ret i32 0 54; 55entry: 56 %cmp = icmp eq i32 %argc, 2 57 br i1 %cmp, label %cond.true, label %cond.end 58 59cond.true: ; preds = %entry 60 %arrayidx = getelementptr inbounds i8*, i8** %argv, i32 1 61 %0 = load i8*, i8** %arrayidx, align 4 62 %call = tail call i32 @atoi(i8* %0) 63 br label %cond.end 64 65cond.end: ; preds = %entry, %cond.true 66 %cond = phi i32 [ %call, %cond.true ], [ 46, %entry ] 67 %1 = mul i32 %cond, %cond 68 %2 = mul i32 %1, %1 69 %3 = mul i32 %cond, %2 70 %4 = icmp sgt i32 %cond, 0 71 %spec.select = select i1 %4, i32 %cond, i32 0 72 %5 = mul i32 %3, %spec.select 73 %call33 = tail call i32 (i8*, ...) @printf(i8* nonnull dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %5) #4 74 ret i32 0 75} 76 77define i32 @test_optsize(i32 %argc, i8** nocapture readonly %argv) local_unnamed_addr #1 { 78; DEFAULT-LABEL: @test_optsize( 79; DEFAULT-NEXT: entry: 80; DEFAULT-NEXT: [[CMP:%.*]] = icmp eq i32 [[ARGC:%.*]], 2 81; DEFAULT-NEXT: br i1 [[CMP]], label [[COND_END:%.*]], label [[COND_END_THREAD:%.*]] 82; DEFAULT: cond.end: 83; DEFAULT-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8*, i8** [[ARGV:%.*]], i32 1 84; DEFAULT-NEXT: [[TMP0:%.*]] = load i8*, i8** [[ARRAYIDX]], align 4 85; DEFAULT-NEXT: [[CALL:%.*]] = tail call i32 @atoi(i8* [[TMP0]]) 86; DEFAULT-NEXT: [[TMP1:%.*]] = mul i32 [[CALL]], [[CALL]] 87; DEFAULT-NEXT: [[TMP2:%.*]] = mul i32 [[TMP1]], [[TMP1]] 88; DEFAULT-NEXT: [[TMP3:%.*]] = mul i32 [[CALL]], [[TMP2]] 89; DEFAULT-NEXT: [[TMP4:%.*]] = icmp sgt i32 [[CALL]], 0 90; DEFAULT-NEXT: br i1 [[TMP4]], label [[COND_END_THREAD]], label [[TMP6:%.*]] 91; DEFAULT: cond.end.thread: 92; DEFAULT-NEXT: [[TMP5:%.*]] = phi i32 [ [[TMP3]], [[COND_END]] ], [ 205962976, [[ENTRY:%.*]] ] 93; DEFAULT-NEXT: [[COND2:%.*]] = phi i32 [ [[CALL]], [[COND_END]] ], [ 46, [[ENTRY]] ] 94; DEFAULT-NEXT: br label [[TMP6]] 95; DEFAULT: 6: 96; DEFAULT-NEXT: [[TMP7:%.*]] = phi i32 [ [[TMP5]], [[COND_END_THREAD]] ], [ [[TMP3]], [[COND_END]] ] 97; DEFAULT-NEXT: [[TMP8:%.*]] = phi i32 [ [[COND2]], [[COND_END_THREAD]] ], [ 0, [[COND_END]] ] 98; DEFAULT-NEXT: [[TMP9:%.*]] = mul i32 [[TMP7]], [[TMP8]] 99; DEFAULT-NEXT: [[CALL33:%.*]] = tail call i32 (i8*, ...) @printf(i8* nonnull dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 [[TMP9]]) 100; DEFAULT-NEXT: ret i32 0 101; 102; OVERIDE-LABEL: @test_optsize( 103; OVERIDE-NEXT: entry: 104; OVERIDE-NEXT: [[CMP:%.*]] = icmp eq i32 [[ARGC:%.*]], 2 105; OVERIDE-NEXT: br i1 [[CMP]], label [[COND_END:%.*]], label [[COND_END_THREAD:%.*]] 106; OVERIDE: cond.end: 107; OVERIDE-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8*, i8** [[ARGV:%.*]], i32 1 108; OVERIDE-NEXT: [[TMP0:%.*]] = load i8*, i8** [[ARRAYIDX]], align 4 109; OVERIDE-NEXT: [[CALL:%.*]] = tail call i32 @atoi(i8* [[TMP0]]) 110; OVERIDE-NEXT: [[TMP1:%.*]] = mul i32 [[CALL]], [[CALL]] 111; OVERIDE-NEXT: [[TMP2:%.*]] = mul i32 [[TMP1]], [[TMP1]] 112; OVERIDE-NEXT: [[TMP3:%.*]] = mul i32 [[CALL]], [[TMP2]] 113; OVERIDE-NEXT: [[TMP4:%.*]] = icmp sgt i32 [[CALL]], 0 114; OVERIDE-NEXT: br i1 [[TMP4]], label [[COND_END_THREAD]], label [[TMP6:%.*]] 115; OVERIDE: cond.end.thread: 116; OVERIDE-NEXT: [[TMP5:%.*]] = phi i32 [ [[TMP3]], [[COND_END]] ], [ 205962976, [[ENTRY:%.*]] ] 117; OVERIDE-NEXT: [[COND2:%.*]] = phi i32 [ [[CALL]], [[COND_END]] ], [ 46, [[ENTRY]] ] 118; OVERIDE-NEXT: br label [[TMP6]] 119; OVERIDE: 6: 120; OVERIDE-NEXT: [[TMP7:%.*]] = phi i32 [ [[TMP5]], [[COND_END_THREAD]] ], [ [[TMP3]], [[COND_END]] ] 121; OVERIDE-NEXT: [[TMP8:%.*]] = phi i32 [ [[COND2]], [[COND_END_THREAD]] ], [ 0, [[COND_END]] ] 122; OVERIDE-NEXT: [[TMP9:%.*]] = mul i32 [[TMP7]], [[TMP8]] 123; OVERIDE-NEXT: [[CALL33:%.*]] = tail call i32 (i8*, ...) @printf(i8* nonnull dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 [[TMP9]]) 124; OVERIDE-NEXT: ret i32 0 125; 126entry: 127 %cmp = icmp eq i32 %argc, 2 128 br i1 %cmp, label %cond.true, label %cond.end 129 130cond.true: ; preds = %entry 131 %arrayidx = getelementptr inbounds i8*, i8** %argv, i32 1 132 %0 = load i8*, i8** %arrayidx, align 4 133 %call = tail call i32 @atoi(i8* %0) 134 br label %cond.end 135 136cond.end: ; preds = %entry, %cond.true 137 %cond = phi i32 [ %call, %cond.true ], [ 46, %entry ] 138 %1 = mul i32 %cond, %cond 139 %2 = mul i32 %1, %1 140 %3 = mul i32 %cond, %2 141 %4 = icmp sgt i32 %cond, 0 142 %spec.select = select i1 %4, i32 %cond, i32 0 143 %5 = mul i32 %3, %spec.select 144 %call33 = tail call i32 (i8*, ...) @printf(i8* nonnull dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %5) #4 145 ret i32 0 146} 147declare i32 @atoi(i8* nocapture) local_unnamed_addr 148declare i32 @printf(i8* nocapture readonly, ...) local_unnamed_addr 149 150attributes #0 = { minsize optsize } 151attributes #1 = { optsize } 152 153