brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.9 KiB · 6574981 Raw
140 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 52; RUN: llc < %s -mtriple=aarch64-unknown-unknown | FileCheck %s3 4define i64 @test_single_or(i64 %unrelated, i64 %x, i64 %y) nounwind {5; CHECK-LABEL: test_single_or:6; CHECK:       // %bb.0:7; CHECK-NEXT:    subs x8, x2, x18; CHECK-NEXT:    ccmp x2, x0, #2, hs9; CHECK-NEXT:    csel x0, xzr, x8, hi10; CHECK-NEXT:    ret11  %cmp.match = icmp ult i64 %y, %x12  %cmp.nomatch = icmp ugt i64 %y, %unrelated13  %or.cond = or i1 %cmp.match, %cmp.nomatch14  %sub.reuse = sub nuw i64 %y, %x15  %res = select i1 %or.cond, i64 0, i64 %sub.reuse16  ret i64 %res17}18 19define i64 @test_two_ors(i64 %unrelated, i64 %x, i64 %y) nounwind {20; CHECK-LABEL: test_two_ors:21; CHECK:       // %bb.0:22; CHECK-NEXT:    subs x8, x2, x123; CHECK-NEXT:    ccmp x0, x1, #0, hs24; CHECK-NEXT:    ccmp x2, x0, #2, hs25; CHECK-NEXT:    csel x0, xzr, x8, hi26; CHECK-NEXT:    ret27  %cmp.match = icmp ult i64 %y, %x28  %cmp.nomatch1 = icmp ult i64 %unrelated, %x29  %cmp.nomatch2 = icmp ugt i64 %y, %unrelated30  %or.nomatch = or i1 %cmp.nomatch1, %cmp.nomatch231  %or.cond = or i1 %cmp.match, %or.nomatch32  %sub.reuse = sub nuw i64 %y, %x33  %res = select i1 %or.cond, i64 0, i64 %sub.reuse34  ret i64 %res35}36 37define i64 @test_two_ors_commuted(i64 %unrelated, i64 %x, i64 %y) nounwind {38; CHECK-LABEL: test_two_ors_commuted:39; CHECK:       // %bb.0:40; CHECK-NEXT:    subs x8, x2, x141; CHECK-NEXT:    ccmp x0, x1, #0, hs42; CHECK-NEXT:    ccmp x2, x0, #2, hs43; CHECK-NEXT:    csel x0, xzr, x8, hi44; CHECK-NEXT:    ret45  %cmp.match = icmp ult i64 %y, %x46  %cmp.nomatch1 = icmp ult i64 %unrelated, %x47  %cmp.nomatch2 = icmp ugt i64 %y, %unrelated48  %or.nomatch = or i1 %cmp.nomatch1, %cmp.nomatch249  %or.cond = or i1 %or.nomatch, %cmp.match50  %sub.reuse = sub nuw i64 %y, %x51  %res = select i1 %or.cond, i64 0, i64 %sub.reuse52  ret i64 %res53}54 55define i64 @test_single_and(i64 %unrelated, i64 %x, i64 %y) nounwind {56; CHECK-LABEL: test_single_and:57; CHECK:       // %bb.0:58; CHECK-NEXT:    subs x8, x2, x159; CHECK-NEXT:    ccmp x2, x0, #0, lo60; CHECK-NEXT:    csel x0, xzr, x8, hi61; CHECK-NEXT:    ret62  %cmp.match = icmp ult i64 %y, %x63  %cmp.nomatch = icmp ugt i64 %y, %unrelated64  %and.cond = and i1 %cmp.match, %cmp.nomatch65  %sub.reuse = sub nuw i64 %y, %x66  %res = select i1 %and.cond, i64 0, i64 %sub.reuse67  ret i64 %res68}69 70define i64 @test_single_or_sub_commuted(i64 %unrelated, i64 %x, i64 %y) nounwind {71; CHECK-LABEL: test_single_or_sub_commuted:72; CHECK:       // %bb.0:73; CHECK-NEXT:    subs x8, x1, x274; CHECK-NEXT:    ccmp x2, x0, #2, ls75; CHECK-NEXT:    csel x0, xzr, x8, hi76; CHECK-NEXT:    ret77  %cmp.match = icmp ult i64 %y, %x78  %cmp.nomatch = icmp ugt i64 %y, %unrelated79  %or.cond = or i1 %cmp.match, %cmp.nomatch80  %sub.reuse = sub nuw i64 %x, %y81  %res = select i1 %or.cond, i64 0, i64 %sub.reuse82  ret i64 %res83}84 85; Negative test: We must negate the or operation, hence this must come first.86define i64 @test_mustbefirst_overrides_preferfirst_negative(i64 %unrelated, i64 %x, i64 %y) nounwind {87; CHECK-LABEL: test_mustbefirst_overrides_preferfirst_negative:88; CHECK:       // %bb.0:89; CHECK-NEXT:    cmp x2, x090; CHECK-NEXT:    sub x8, x2, x191; CHECK-NEXT:    ccmp x0, x1, #0, ls92; CHECK-NEXT:    ccmp x2, x1, #2, lo93; CHECK-NEXT:    csel x0, xzr, x8, lo94; CHECK-NEXT:    ret95  %cmp.match = icmp ult i64 %y, %x96  %cmp.nomatch1 = icmp ult i64 %unrelated, %x97  %cmp.nomatch2 = icmp ugt i64 %y, %unrelated98  %or.nomatch = or i1 %cmp.nomatch1, %cmp.nomatch299  %and.cond = and i1 %or.nomatch, %cmp.match100  %sub.reuse = sub nuw i64 %y, %x101  %res = select i1 %and.cond, i64 0, i64 %sub.reuse102  ret i64 %res103}104 105; Negative test: There is no analogue of SUBS for floating point.106define float @test_negative_float(float %unrelated, float %x, float %y) nounwind {107; CHECK-LABEL: test_negative_float:108; CHECK:       // %bb.0:109; CHECK-NEXT:    fcmp s2, s0110; CHECK-NEXT:    fsub s0, s2, s1111; CHECK-NEXT:    movi d3, #0000000000000000112; CHECK-NEXT:    fccmp s2, s1, #8, le113; CHECK-NEXT:    fcsel s0, s3, s0, mi114; CHECK-NEXT:    ret115  %cmp.nomatch1 = fcmp olt float %y, %x116  %cmp.nomatch2 = fcmp ogt float %y, %unrelated117  %or.cond = or i1 %cmp.nomatch1, %cmp.nomatch2118  %sub.noreuse = fsub float %y, %x119  %res = select i1 %or.cond, float 0.0, float %sub.noreuse120  ret float %res121}122 123; Negative test: If both operands match a sub, do not reorder them.124define i64 @test_prefer_right_negative(i64 %x, i64 %y, i64 %z) nounwind {125; CHECK-LABEL: test_prefer_right_negative:126; CHECK:       // %bb.0:127; CHECK-NEXT:    cmp x2, x0128; CHECK-NEXT:    ccmp x2, x1, #0, ls129; CHECK-NEXT:    csel x8, x0, x1, lo130; CHECK-NEXT:    sub x0, x2, x8131; CHECK-NEXT:    ret132  %cmp.match1 = icmp ult i64 %z, %y133  %cmp.match2 = icmp ugt i64 %z, %x134  %or.cond = or i1 %cmp.match1, %cmp.match2135  %sub.reuse1 = sub nuw i64 %z, %y136  %sub.reuse2 = sub nuw i64 %z, %x137  %res = select i1 %or.cond, i64 %sub.reuse2, i64 %sub.reuse1138  ret i64 %res139}140