brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.1 KiB · 4303cac Raw
318 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s3 4define i1 @test_second_or_condition_implied_by_first(i8 %x) {5; CHECK-LABEL: @test_second_or_condition_implied_by_first(6; CHECK-NEXT:  entry:7; CHECK-NEXT:    [[C_1:%.*]] = icmp ule i8 [[X:%.*]], 108; CHECK-NEXT:    [[T_1:%.*]] = icmp ugt i8 [[X]], 59; CHECK-NEXT:    br i1 true, label [[THEN:%.*]], label [[ELSE:%.*]]10; CHECK:       then:11; CHECK-NEXT:    ret i1 false12; CHECK:       else:13; CHECK-NEXT:    ret i1 true14;15entry:16  %c.1 = icmp ule i8 %x, 1017  %t.1 = icmp ugt i8 %x, 518  %or = or i1 %c.1, %t.119  br i1 %or, label %then, label %else20 21then:22  ret i1 023 24else:25  ret i1 126}27 28define i1 @test_first_or_condition_implied_by_second_ops(i8 %x) {29; CHECK-LABEL: @test_first_or_condition_implied_by_second_ops(30; CHECK-NEXT:  entry:31; CHECK-NEXT:    [[C_1:%.*]] = icmp ule i8 [[X:%.*]], 1032; CHECK-NEXT:    [[T_1:%.*]] = icmp ugt i8 [[X]], 533; CHECK-NEXT:    br i1 true, label [[THEN:%.*]], label [[ELSE:%.*]]34; CHECK:       then:35; CHECK-NEXT:    ret i1 false36; CHECK:       else:37; CHECK-NEXT:    ret i1 true38;39entry:40  %c.1 = icmp ule i8 %x, 1041  %t.1 = icmp ugt i8 %x, 542  %or = or i1 %t.1, %c.143  br i1 %or, label %then, label %else44 45then:46  ret i1 047 48else:49  ret i1 150}51 52define i1 @test_second_or_condition_implied_by_first_select_form(i8 %x) {53; CHECK-LABEL: @test_second_or_condition_implied_by_first_select_form(54; CHECK-NEXT:  entry:55; CHECK-NEXT:    [[C_1:%.*]] = icmp ule i8 [[X:%.*]], 1056; CHECK-NEXT:    [[T_1:%.*]] = icmp ugt i8 [[X]], 557; CHECK-NEXT:    [[OR:%.*]] = select i1 [[C_1]], i1 false, i1 [[T_1]]58; CHECK-NEXT:    br i1 [[OR]], label [[THEN:%.*]], label [[ELSE:%.*]]59; CHECK:       then:60; CHECK-NEXT:    ret i1 false61; CHECK:       else:62; CHECK-NEXT:    ret i1 true63;64entry:65  %c.1 = icmp ule i8 %x, 1066  %t.1 = icmp ugt i8 %x, 567  %or = select i1 %c.1, i1 false, i1 %t.168  br i1 %or, label %then, label %else69 70then:71  ret i1 072 73else:74  ret i1 175}76 77define i1 @test_first_or_condition_implied_by_second_select_form(i8 %x) {78; CHECK-LABEL: @test_first_or_condition_implied_by_second_select_form(79; CHECK-NEXT:  entry:80; CHECK-NEXT:    [[C_1:%.*]] = icmp ule i8 [[X:%.*]], 1081; CHECK-NEXT:    [[T_1:%.*]] = icmp ugt i8 [[X]], 582; CHECK-NEXT:    [[OR:%.*]] = select i1 [[T_1]], i1 false, i1 [[C_1]]83; CHECK-NEXT:    br i1 [[OR]], label [[THEN:%.*]], label [[ELSE:%.*]]84; CHECK:       then:85; CHECK-NEXT:    ret i1 false86; CHECK:       else:87; CHECK-NEXT:    ret i1 true88;89entry:90  %c.1 = icmp ule i8 %x, 1091  %t.1 = icmp ugt i8 %x, 592  %or = select i1 %t.1, i1 false, i1 %c.193  br i1 %or, label %then, label %else94 95then:96  ret i1 097 98else:99  ret i1 1100}101 102define i1 @test_same_cond_for_or(i8 %x) {103; CHECK-LABEL: @test_same_cond_for_or(104; CHECK-NEXT:  entry:105; CHECK-NEXT:    [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10106; CHECK-NEXT:    br i1 [[C_1]], label [[THEN:%.*]], label [[ELSE:%.*]]107; CHECK:       then:108; CHECK-NEXT:    ret i1 false109; CHECK:       else:110; CHECK-NEXT:    ret i1 true111;112entry:113  %c.1 = icmp ugt i8 %x, 10114  %or = or i1 %c.1, %c.1115  br i1 %or, label %then, label %else116 117then:118  ret i1 0119 120else:121  ret i1 1122}123 124define i1 @test_same_cond_for_or_select_form(i8 %x) {125; CHECK-LABEL: @test_same_cond_for_or_select_form(126; CHECK-NEXT:  entry:127; CHECK-NEXT:    [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10128; CHECK-NEXT:    [[OR:%.*]] = select i1 [[C_1]], i1 false, i1 [[C_1]]129; CHECK-NEXT:    br i1 [[OR]], label [[THEN:%.*]], label [[ELSE:%.*]]130; CHECK:       then:131; CHECK-NEXT:    ret i1 false132; CHECK:       else:133; CHECK-NEXT:    ret i1 true134;135entry:136  %c.1 = icmp ugt i8 %x, 10137  %or = select i1 %c.1, i1 false, i1 %c.1138  br i1 %or, label %then, label %else139 140then:141  ret i1 0142 143else:144  ret i1 1145}146 147define i1 @test_second_or_condition_not_implied_by_first(i8 %x) {148; CHECK-LABEL: @test_second_or_condition_not_implied_by_first(149; CHECK-NEXT:  entry:150; CHECK-NEXT:    [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10151; CHECK-NEXT:    [[C_2:%.*]] = icmp ugt i8 [[X]], 5152; CHECK-NEXT:    br i1 [[C_2]], label [[THEN:%.*]], label [[ELSE:%.*]]153; CHECK:       then:154; CHECK-NEXT:    ret i1 false155; CHECK:       else:156; CHECK-NEXT:    ret i1 true157;158entry:159  %c.1 = icmp ugt i8 %x, 10160  %c.2 = icmp ugt i8 %x, 5161  %or = or i1 %c.2, %c.1162  br i1 %or, label %then, label %else163 164then:165  ret i1 0166 167else:168  ret i1 1169}170 171define i1 @test_remove_variables(i1 %c, ptr %A, i64 %B, ptr %C) {172; CHECK-LABEL: @test_remove_variables(173; CHECK-NEXT:  entry:174; CHECK-NEXT:    br i1 [[C:%.*]], label [[THEN_1:%.*]], label [[EXIT:%.*]]175; CHECK:       then.1:176; CHECK-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[C:%.*]], align 8177; CHECK-NEXT:    [[C_1:%.*]] = icmp ult ptr [[TMP0]], [[A:%.*]]178; CHECK-NEXT:    br i1 [[C_1]], label [[THEN_2:%.*]], label [[ELSE_2:%.*]]179; CHECK:       then.2:180; CHECK-NEXT:    [[C_3:%.*]] = icmp sgt i64 [[B:%.*]], 0181; CHECK-NEXT:    [[OR:%.*]] = or i1 true, [[C_3]]182; CHECK-NEXT:    ret i1 [[OR]]183; CHECK:       else.2:184; CHECK-NEXT:    ret i1 false185; CHECK:       exit:186; CHECK-NEXT:    ret i1 true187;188entry:189  br i1 %c, label %then.1, label %exit190 191then.1:192  %0 = load ptr, ptr %C, align 8193  %c.1 = icmp ult ptr %0, %A194  br i1 %c.1, label %then.2, label %else.2195 196then.2:197  %c.2 = icmp ne ptr %A, null198  %c.3 = icmp sgt i64 %B, 0199  %or = or i1 %c.2, %c.3200  ret i1 %or201 202else.2:203  ret i1 0204 205exit:206  %t = icmp eq ptr null, null207  ret i1 %t208}209 210define i1 @test_or_op_0_simplified(i32 %v) {211; CHECK-LABEL: @test_or_op_0_simplified(212; CHECK-NEXT:  entry:213; CHECK-NEXT:    [[C_1:%.*]] = icmp sgt i32 [[V:%.*]], 0214; CHECK-NEXT:    [[OR:%.*]] = or i1 false, [[C_1]]215; CHECK-NEXT:    ret i1 [[OR]]216;217entry:218  %c.1 = icmp sgt i32 %v, 0219  %t.1 = icmp sgt i32 0, 0220  %or = or i1 %t.1, %c.1221  ret i1 %or222}223 224define i1 @test_or_op_1_simplified(i32 %v) {225; CHECK-LABEL: @test_or_op_1_simplified(226; CHECK-NEXT:  entry:227; CHECK-NEXT:    [[C_1:%.*]] = icmp sgt i32 [[V:%.*]], 0228; CHECK-NEXT:    [[OR:%.*]] = or i1 [[C_1]], false229; CHECK-NEXT:    ret i1 [[OR]]230;231entry:232  %c.1 = icmp sgt i32 %v, 0233  %t.1 = icmp sgt i32 0, 0234  %or = or i1 %c.1, %t.1235  ret i1 %or236}237 238define i1 @test_or_used_in_false_branch(i8 %x) {239; CHECK-LABEL: @test_or_used_in_false_branch(240; CHECK-NEXT:  entry:241; CHECK-NEXT:    [[C_1:%.*]] = icmp ule i8 [[X:%.*]], 10242; CHECK-NEXT:    [[T_1:%.*]] = icmp ule i8 [[X]], 5243; CHECK-NEXT:    br i1 [[C_1]], label [[THEN:%.*]], label [[ELSE:%.*]]244; CHECK:       then:245; CHECK-NEXT:    ret i1 [[T_1]]246; CHECK:       else:247; CHECK-NEXT:    ret i1 false248;249 250entry:251  %c.1 = icmp ule i8 %x, 10252  %t.1 = icmp ule i8 %x, 5253  %or = or i1 %c.1, %t.1254  br i1 %or, label %then, label %else255 256then:257  ret i1 %t.1258 259else:260  ret i1 %t.1261}262 263define i1 @test_or_used_in_false_branch2(i8 %x) {264; CHECK-LABEL: @test_or_used_in_false_branch2(265; CHECK-NEXT:  entry:266; CHECK-NEXT:    [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10267; CHECK-NEXT:    [[T_1:%.*]] = icmp ugt i8 [[X]], 5268; CHECK-NEXT:    br i1 [[T_1]], label [[THEN:%.*]], label [[ELSE:%.*]]269; CHECK:       then:270; CHECK-NEXT:    ret i1 [[T_1]]271; CHECK:       else:272; CHECK-NEXT:    ret i1 false273;274 275entry:276  %c.1 = icmp ugt i8 %x, 10277  %t.1 = icmp ugt i8 %x, 5278  %or = or i1 %c.1, %t.1279  br i1 %or, label %then, label %else280 281then:282  ret i1 %t.1283 284else:285  ret i1 %t.1286}287 288define i1 @select_or_set_operand(ptr noundef %a, ptr noundef %b) {289; CHECK-LABEL: @select_or_set_operand(290; CHECK-NEXT:  entry:291; CHECK-NEXT:    [[CMP_EQ:%.*]] = icmp eq ptr [[A:%.*]], [[B:%.*]]292; CHECK-NEXT:    [[INCDEC_PTR12_I:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 1293; CHECK-NEXT:    [[CMP_EQ_1:%.*]] = icmp eq ptr [[INCDEC_PTR12_I]], [[B]]294; CHECK-NEXT:    [[OR:%.*]] = select i1 [[CMP_EQ]], i1 true, i1 [[CMP_EQ_1]]295; CHECK-NEXT:    ret i1 [[OR]]296;297entry:298  %cmp.eq = icmp eq ptr %a, %b299  %incdec.ptr12.i = getelementptr inbounds i32, ptr %a, i64 1300  %cmp.eq.1 = icmp eq ptr %incdec.ptr12.i, %b301  %or = select i1 %cmp.eq, i1 true, i1 %cmp.eq.1302  ret i1 %or303}304 305define i1 @test_or_disjoint_set_operand(i8 %x) {306; CHECK-LABEL: @test_or_disjoint_set_operand(307; CHECK-NEXT:  entry:308; CHECK-NEXT:    [[CMP1:%.*]] = icmp slt i8 [[X:%.*]], 1309; CHECK-NEXT:    [[CMP2:%.*]] = icmp ne i8 [[X]], 0310; CHECK-NEXT:    ret i1 true311;312entry:313  %cmp1 = icmp slt i8 %x, 1314  %cmp2 = icmp ne i8 %x, 0315  %or = or disjoint i1 %cmp2, %cmp1316  ret i1 %or317}318