222 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 32; RUN: opt -passes='default<O2>' -S %s | FileCheck %s3 4target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"5target triple = "arm64-apple-macosx"6 7define i1 @test_order_1(ptr %this, ptr noalias %other, i1 %tobool9.not, i32 %call) {8; CHECK-LABEL: define noundef i1 @test_order_1(9; CHECK-SAME: ptr writeonly captures(none) [[THIS:%.*]], ptr noalias [[OTHER:%.*]], i1 [[TOBOOL9_NOT:%.*]], i32 [[CALL:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {10; CHECK-NEXT: entry:11; CHECK-NEXT: br i1 [[TOBOOL9_NOT]], label [[EXIT:%.*]], label [[FOR_COND_PREHEADER:%.*]]12; CHECK: for.cond.preheader:13; CHECK-NEXT: [[CMP40_NOT3:%.*]] = icmp sgt i32 [[CALL]], 014; CHECK-NEXT: br i1 [[CMP40_NOT3]], label [[FOR_COND41_PREHEADER_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]15; CHECK: for.cond41.preheader.preheader:16; CHECK-NEXT: [[TMP0:%.*]] = sext i32 [[CALL]] to i6417; CHECK-NEXT: br label [[FOR_COND41_PREHEADER:%.*]]18; CHECK: for.cond41.preheader:19; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[TMP0]], [[FOR_COND_CLEANUP]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_COND:%.*]] ]20; CHECK-NEXT: [[CALL431:%.*]] = load volatile i32, ptr [[OTHER]], align 421; CHECK-NEXT: [[CMP442:%.*]] = icmp sgt i32 [[CALL431]], 022; CHECK-NEXT: br i1 [[CMP442]], label [[FOR_BODY45_LR_PH:%.*]], label [[FOR_COND]]23; CHECK: for.body45.lr.ph:24; CHECK-NEXT: [[ARRAYIDX_I_I:%.*]] = getelementptr ptr, ptr [[OTHER]], i64 [[INDVARS_IV]]25; CHECK-NEXT: br label [[FOR_BODY45:%.*]]26; CHECK: for.cond.cleanup:27; CHECK-NEXT: store i32 0, ptr [[THIS]], align 428; CHECK-NEXT: br label [[EXIT]]29; CHECK: for.body45:30; CHECK-NEXT: [[CALL49:%.*]] = load volatile i1, ptr [[ARRAYIDX_I_I]], align 131; CHECK-NEXT: [[CALL43:%.*]] = load volatile i32, ptr [[OTHER]], align 432; CHECK-NEXT: [[CMP44:%.*]] = icmp sgt i32 [[CALL43]], 033; CHECK-NEXT: br i1 [[CMP44]], label [[FOR_BODY45]], label [[FOR_COND]]34; CHECK: for.inc57:35; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 136; CHECK-NEXT: [[TMP1:%.*]] = and i64 [[INDVARS_IV_NEXT]], 429496729537; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[TMP1]], 138; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_COND41_PREHEADER_PREHEADER]], label [[FOR_COND41_PREHEADER]]39; CHECK: exit:40; CHECK-NEXT: ret i1 false41;42entry:43 %retval1 = alloca i1, i32 0, align 144 br i1 %tobool9.not, label %exit, label %for.cond45 46for.cond: ; preds = %for.inc57, %entry47 %0 = phi i32 [ %inc58, %for.inc57 ], [ %call, %entry ]48 %cmp40.not = icmp sgt i32 %0, 049 br i1 %cmp40.not, label %for.cond.cleanup, label %for.cond4150 51for.cond.cleanup: ; preds = %for.cond52 store i32 0, ptr %this, align 453 br label %cleanup5954 55for.cond41: ; preds = %for.body45, %for.cond56 %call43 = load volatile i32, ptr %other, align 457 %cmp44 = icmp sgt i32 %call43, 058 br i1 %cmp44, label %for.body45, label %for.end59 60for.body45: ; preds = %for.cond4161 %idxprom.i.i = sext i32 %0 to i6462 %arrayidx.i.i = getelementptr ptr, ptr %other, i64 %idxprom.i.i63 %call49 = load volatile i1, ptr %arrayidx.i.i, align 164 br label %for.cond4165 66for.end: ; preds = %for.cond4167 br i1 %tobool9.not, label %cleanup59, label %for.inc5768 69for.inc57: ; preds = %for.end70 %inc58 = add nsw i32 %0, 171 br label %for.cond72 73cleanup59: ; preds = %for.end, %for.cond.cleanup74 %cleanup.dest60 = phi i32 [ 0, %for.end ], [ 2, %for.cond.cleanup ]75 %cond1 = icmp eq i32 %cleanup.dest60, 276 br i1 %cond1, label %for.end61, label %exit77 78for.end61: ; preds = %cleanup5979 store i1 false, ptr %retval1, align 180 br label %exit81 82exit: ; preds = %for.end61, %cleanup59, %entry83 %1 = phi i1 [ false, %for.end61 ], [ true, %cleanup59 ], [ false, %entry ]84 ret i1 %185}86 87%struct = type { ptr, i64, i64 }88 89@.str.78 = constant [12 x i8] c"--test-info\00"90@.str.79 = constant [14 x i8] c"--test-noinfo\00"91@.str.80 = constant [18 x i8] c"--test-nocompress\00"92 93declare i64 @strlen(ptr)94 95define void @test2(ptr %this) #0 {96; CHECK-LABEL: define void @test2(97; CHECK-SAME: ptr writeonly captures(none) [[THIS:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] {98; CHECK-NEXT: entry:99; CHECK-NEXT: [[CALL1_I_I:%.*]] = tail call i1 @test2_fn4(i8 undef)100; CHECK-NEXT: [[CALL2_I_I:%.*]] = load i64, ptr inttoptr (i64 8 to ptr), align 8101; CHECK-NEXT: [[COND38:%.*]] = icmp eq i64 [[CALL2_I_I]], 13102; CHECK-NEXT: [[COND:%.*]] = select i1 [[CALL1_I_I]], i1 [[COND38]], i1 false103; CHECK-NEXT: br i1 [[COND]], label [[TEST2_FN2_EXIT12:%.*]], label [[COMMON_RET:%.*]]104; CHECK: test2_fn2.exit12:105; CHECK-NEXT: [[CALL8_I_I8:%.*]] = tail call fastcc noundef i32 @test2_fn6()106; CHECK-NEXT: [[CMP4_I11:%.*]] = icmp eq i32 [[CALL8_I_I8]], 0107; CHECK-NEXT: br i1 [[CMP4_I11]], label [[TEST2_FN2_EXIT24:%.*]], label [[COMMON_RET]]108; CHECK: common.ret:109; CHECK-NEXT: ret void110; CHECK: test2_fn2.exit24:111; CHECK-NEXT: store i8 0, ptr [[THIS]], align 4112; CHECK-NEXT: br label [[COMMON_RET]]113;114entry:115 %call16 = call i1 @test2_fn2(ptr @.str.78)116 %call17 = call i1 @test2_fn2(ptr @.str.79)117 br i1 %call17, label %if.then18, label %if.else21118 119common.ret: ; preds = %if.else21, %if.then18120 ret void121 122if.then18: ; preds = %entry123 %call19 = call i1 @test2_fn2(ptr @.str.78)124 %frombool20 = zext i1 %call19 to i8125 store i8 %frombool20, ptr %this, align 4126 br label %common.ret127 128if.else21: ; preds = %entry129 %call22 = call i1 @test2_fn2(ptr @.str.80)130 br label %common.ret131}132 133define i1 @test2_fn2(ptr %__rhs) #0 {134; CHECK-LABEL: define noundef i1 @test2_fn2(135; CHECK-SAME: ptr readonly captures(none) [[__RHS:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] {136; CHECK-NEXT: entry:137; CHECK-NEXT: [[CALL:%.*]] = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) [[__RHS]])138; CHECK-NEXT: [[CALL1_I:%.*]] = tail call i1 @test2_fn4(i8 undef)139; CHECK-NEXT: [[CALL2_I:%.*]] = load i64, ptr inttoptr (i64 8 to ptr), align 8140; CHECK-NEXT: [[COND_I:%.*]] = select i1 [[CALL1_I]], i64 [[CALL2_I]], i64 0141; CHECK-NEXT: [[CMP2_NOT:%.*]] = icmp eq i64 [[CALL]], [[COND_I]]142; CHECK-NEXT: br i1 [[CMP2_NOT]], label [[IF_END:%.*]], label [[CLEANUP:%.*]]143; CHECK: if.end:144; CHECK-NEXT: [[CALL8_I:%.*]] = tail call fastcc noundef i32 @test2_fn6()145; CHECK-NEXT: [[CMP4:%.*]] = icmp eq i32 [[CALL8_I]], 0146; CHECK-NEXT: br label [[CLEANUP]]147; CHECK: cleanup:148; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i1 [ [[CMP4]], [[IF_END]] ], [ false, [[ENTRY:%.*]] ]149; CHECK-NEXT: ret i1 [[RETVAL_0]]150;151entry:152 %call = call i64 @strlen(ptr %__rhs)153 %call1 = call i64 @test2_fn3(ptr null)154 %cmp2.not = icmp eq i64 %call, %call1155 br i1 %cmp2.not, label %if.end, label %cleanup156 157if.end: ; preds = %entry158 %call3 = call i32 @test2_fn5()159 %cmp4 = icmp eq i32 %call3, 0160 br label %cleanup161 162cleanup: ; preds = %if.end, %entry163 %retval.0 = phi i1 [ %cmp4, %if.end ], [ false, %entry ]164 ret i1 %retval.0165}166 167declare void @llvm.assume(i1 noundef)168 169define internal i64 @test2_fn3(ptr align 8 dereferenceable(24) %this) #0 {170entry:171 %l = load i8, ptr %this172 %call1 = call i1 @test2_fn4(i8 %l)173 br i1 %call1, label %cond.true, label %cond.end174 175cond.true: ; preds = %entry176 %__size_ = getelementptr %struct, ptr %this, i64 0, i32 1177 %call2 = load i64, ptr %__size_, align 8178 179 br label %cond.end180 181cond.end: ; preds = %cond.true, %entry182 %cond = phi i64 [ %call2, %cond.true ], [ 0, %entry ]183 ret i64 %cond184}185 186define i1 @test2_fn4(i8 %bf.load) {187; CHECK-LABEL: define i1 @test2_fn4(188; CHECK-SAME: i8 [[BF_LOAD:%.*]]) local_unnamed_addr #[[ATTR4:[0-9]+]] {189; CHECK-NEXT: entry:190; CHECK-NEXT: [[TOBOOL:%.*]] = icmp slt i8 [[BF_LOAD]], 0191; CHECK-NEXT: ret i1 [[TOBOOL]]192;193entry:194 %tobool = icmp slt i8 %bf.load, 0195 ret i1 %tobool196}197 198define internal i32 @test2_fn5() #0 {199entry:200 %call8 = call i32 @test2_fn6()201 %trunc = trunc i32 %call8 to i8202 %call1 = call i1 @test2_fn4(i8 %trunc)203 %0 = xor i1 %call1, true204 call void @llvm.assume(i1 %0)205 ret i32 %call8206}207 208define internal i32 @test2_fn6() {209; CHECK-LABEL: define internal fastcc noundef i32 @test2_fn6(210; CHECK-SAME: ) unnamed_addr #[[ATTR4]] {211; CHECK-NEXT: entry:212; CHECK-NEXT: ret i32 0213;214entry:215 %call = call i32 @memcmp(ptr @.str.79, ptr @.str.79, i64 2)216 ret i32 %call217}218 219declare i32 @memcmp(ptr, ptr, i64)220 221attributes #0 = { "target-cpu"="apple-m1" }222