brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.7 KiB · 620d978 Raw
213 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 52; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s3 4define i1 @test_icmp_ult_zext_icmp_trunc_nuw(i16 %x, i32 %y) {5; CHECK-LABEL: define i1 @test_icmp_ult_zext_icmp_trunc_nuw(6; CHECK-SAME: i16 [[X:%.*]], i32 [[Y:%.*]]) {7; CHECK-NEXT:    [[EXT:%.*]] = zext i16 [[X]] to i328; CHECK-NEXT:    [[COND:%.*]] = icmp ult i32 [[Y]], [[EXT]]9; CHECK-NEXT:    br i1 [[COND]], label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]]10; CHECK:       [[IF_THEN]]:11; CHECK-NEXT:    [[CONV:%.*]] = trunc nuw i32 [[Y]] to i1612; CHECK-NEXT:    ret i1 false13; CHECK:       [[IF_ELSE]]:14; CHECK-NEXT:    ret i1 false15;16  %ext = zext i16 %x to i3217  %cond = icmp ult i32 %y, %ext18  br i1 %cond, label %if.then, label %if.else19 20if.then:21  %conv = trunc nuw i32 %y to i1622  %cmp = icmp eq i16 %x, %conv23  ret i1 %cmp24 25if.else:26  ret i1 false27}28 29define i1 @test_icmp_slt_sext_icmp_trunc_nsw(i16 %x, i32 %y) {30; CHECK-LABEL: define i1 @test_icmp_slt_sext_icmp_trunc_nsw(31; CHECK-SAME: i16 [[X:%.*]], i32 [[Y:%.*]]) {32; CHECK-NEXT:    [[EXT:%.*]] = sext i16 [[X]] to i3233; CHECK-NEXT:    [[COND:%.*]] = icmp slt i32 [[Y]], [[EXT]]34; CHECK-NEXT:    br i1 [[COND]], label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]]35; CHECK:       [[IF_THEN]]:36; CHECK-NEXT:    [[CONV:%.*]] = trunc nsw i32 [[Y]] to i1637; CHECK-NEXT:    ret i1 false38; CHECK:       [[IF_ELSE]]:39; CHECK-NEXT:    ret i1 false40;41  %ext = sext i16 %x to i3242  %cond = icmp slt i32 %y, %ext43  br i1 %cond, label %if.then, label %if.else44 45if.then:46  %conv = trunc nsw i32 %y to i1647  %cmp = icmp slt i16 %x, %conv48  ret i1 %cmp49 50if.else:51  ret i1 false52}53 54define i1 @test_icmp_ult_trunc_nsw_nneg_icmp_trunc_nuw(i64 %x, i32 %y) {55; CHECK-LABEL: define i1 @test_icmp_ult_trunc_nsw_nneg_icmp_trunc_nuw(56; CHECK-SAME: i64 [[X:%.*]], i32 [[Y:%.*]]) {57; CHECK-NEXT:    [[EXT:%.*]] = trunc nsw i64 [[X]] to i3258; CHECK-NEXT:    [[NNEG:%.*]] = icmp sgt i64 [[X]], -159; CHECK-NEXT:    [[COND:%.*]] = icmp ult i32 [[Y]], [[EXT]]60; CHECK-NEXT:    [[AND:%.*]] = and i1 [[NNEG]], [[COND]]61; CHECK-NEXT:    br i1 [[AND]], label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]]62; CHECK:       [[IF_THEN]]:63; CHECK-NEXT:    [[CONV:%.*]] = zext i32 [[Y]] to i6464; CHECK-NEXT:    ret i1 false65; CHECK:       [[IF_ELSE]]:66; CHECK-NEXT:    ret i1 false67;68  %ext = trunc nsw i64 %x to i3269  %nneg = icmp sgt i64 %x, -170  %cond = icmp ult i32 %y, %ext71  %and = and i1 %nneg, %cond72  br i1 %and, label %if.then, label %if.else73 74if.then:75  %conv = zext i32 %y to i6476  %cmp = icmp eq i64 %x, %conv77  ret i1 %cmp78 79if.else:80  ret i1 false81}82 83define i1 @test2(i32 %n) {84; CHECK-LABEL: define i1 @test2(85; CHECK-SAME: i32 [[N:%.*]]) {86; CHECK-NEXT:    [[COND:%.*]] = icmp sgt i32 [[N]], 087; CHECK-NEXT:    br i1 [[COND]], label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]]88; CHECK:       [[IF_THEN]]:89; CHECK-NEXT:    [[EXT:%.*]] = zext nneg i32 [[N]] to i6490; CHECK-NEXT:    [[END:%.*]] = add nsw i64 [[EXT]], -191; CHECK-NEXT:    br label %[[FOR_BODY:.*]]92; CHECK:       [[FOR_BODY]]:93; CHECK-NEXT:    [[INDVAR:%.*]] = phi i64 [ 0, %[[IF_THEN]] ], [ [[INDVAR_NEXT:%.*]], %[[FOR_NEXT:.*]] ]94; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i64 [[INDVAR]], [[END]]95; CHECK-NEXT:    br i1 [[CMP]], label %[[IF_ELSE]], label %[[FOR_NEXT]]96; CHECK:       [[FOR_NEXT]]:97; CHECK-NEXT:    [[INDVAR_NEXT]] = add nuw nsw i64 [[INDVAR]], 198; CHECK-NEXT:    [[COND2:%.*]] = call i1 @cond()99; CHECK-NEXT:    br i1 [[COND2]], label %[[FOR_BODY]], label %[[FOR_END:.*]]100; CHECK:       [[FOR_END]]:101; CHECK-NEXT:    [[TRUNC:%.*]] = trunc nsw i64 [[INDVAR_NEXT]] to i32102; CHECK-NEXT:    ret i1 true103; CHECK:       [[IF_ELSE]]:104; CHECK-NEXT:    ret i1 false105;106  %cond = icmp sgt i32 %n, 0107  br i1 %cond, label %if.then, label %if.else108 109if.then:110  %ext = zext nneg i32 %n to i64111  %end = add nsw i64 %ext, -1112  br label %for.body113 114for.body:115  %indvar = phi i64 [ 0, %if.then ], [ %indvar.next, %for.next ]116  %cmp = icmp eq i64 %indvar, %end117  br i1 %cmp, label %if.else, label %for.next118 119for.next:120  %indvar.next = add nuw nsw i64 %indvar, 1121  %cond2 = call i1 @cond()122  br i1 %cond2, label %for.body, label %for.end123 124for.end:125  %trunc = trunc nsw i64 %indvar.next to i32126  %res = icmp sgt i32 %n, %trunc127  ret i1 %res128 129if.else:130  ret i1 false131}132 133define i1 @test_icmp_ult_zext_icmp_trunc(i16 %x, i32 %y) {134; CHECK-LABEL: define i1 @test_icmp_ult_zext_icmp_trunc(135; CHECK-SAME: i16 [[X:%.*]], i32 [[Y:%.*]]) {136; CHECK-NEXT:    [[EXT:%.*]] = zext i16 [[X]] to i32137; CHECK-NEXT:    [[COND:%.*]] = icmp ult i32 [[Y]], [[EXT]]138; CHECK-NEXT:    br i1 [[COND]], label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]]139; CHECK:       [[IF_THEN]]:140; CHECK-NEXT:    [[CONV:%.*]] = trunc i32 [[Y]] to i16141; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i16 [[X]], [[CONV]]142; CHECK-NEXT:    ret i1 [[CMP]]143; CHECK:       [[IF_ELSE]]:144; CHECK-NEXT:    ret i1 false145;146  %ext = zext i16 %x to i32147  %cond = icmp ult i32 %y, %ext148  br i1 %cond, label %if.then, label %if.else149 150if.then:151  %conv = trunc i32 %y to i16152  %cmp = icmp eq i16 %x, %conv153  ret i1 %cmp154 155if.else:156  ret i1 false157}158 159define i1 @test_icmp_ult_zext_icmp_trunc_nuw_i128(i16 %x, i128 %y) {160; CHECK-LABEL: define i1 @test_icmp_ult_zext_icmp_trunc_nuw_i128(161; CHECK-SAME: i16 [[X:%.*]], i128 [[Y:%.*]]) {162; CHECK-NEXT:    [[EXT:%.*]] = zext i16 [[X]] to i128163; CHECK-NEXT:    [[COND:%.*]] = icmp ult i128 [[Y]], [[EXT]]164; CHECK-NEXT:    br i1 [[COND]], label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]]165; CHECK:       [[IF_THEN]]:166; CHECK-NEXT:    [[CONV:%.*]] = trunc nuw i128 [[Y]] to i16167; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i16 [[X]], [[CONV]]168; CHECK-NEXT:    ret i1 [[CMP]]169; CHECK:       [[IF_ELSE]]:170; CHECK-NEXT:    ret i1 false171;172  %ext = zext i16 %x to i128173  %cond = icmp ult i128 %y, %ext174  br i1 %cond, label %if.then, label %if.else175 176if.then:177  %conv = trunc nuw i128 %y to i16178  %cmp = icmp eq i16 %x, %conv179  ret i1 %cmp180 181if.else:182  ret i1 false183}184 185; We do not know the sign of %x, so we cannot infer nuw for %ext.186define i1 @test_icmp_ult_trunc_nsw_icmp_trunc_nuw(i64 %x, i32 %y) {187; CHECK-LABEL: define i1 @test_icmp_ult_trunc_nsw_icmp_trunc_nuw(188; CHECK-SAME: i64 [[X:%.*]], i32 [[Y:%.*]]) {189; CHECK-NEXT:    [[EXT:%.*]] = trunc nsw i64 [[X]] to i32190; CHECK-NEXT:    [[COND:%.*]] = icmp ult i32 [[Y]], [[EXT]]191; CHECK-NEXT:    br i1 [[COND]], label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]]192; CHECK:       [[IF_THEN]]:193; CHECK-NEXT:    [[CONV:%.*]] = zext i32 [[Y]] to i64194; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i64 [[X]], [[CONV]]195; CHECK-NEXT:    ret i1 [[CMP]]196; CHECK:       [[IF_ELSE]]:197; CHECK-NEXT:    ret i1 false198;199  %ext = trunc nsw i64 %x to i32200  %cond = icmp ult i32 %y, %ext201  br i1 %cond, label %if.then, label %if.else202 203if.then:204  %conv = zext i32 %y to i64205  %cmp = icmp eq i64 %x, %conv206  ret i1 %cmp207 208if.else:209  ret i1 false210}211 212declare void @cond()213