brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.2 KiB · d307107 Raw
198 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s3 4; CodeGenPrepare is expected to form overflow intrinsics to improve DAG/isel.5 6define i1 @usubo_ult_i64(i64 %x, i64 %y, ptr %p) nounwind {7; CHECK-LABEL: usubo_ult_i64:8; CHECK:       // %bb.0:9; CHECK-NEXT:    subs x8, x0, x110; CHECK-NEXT:    cset w0, lo11; CHECK-NEXT:    str x8, [x2]12; CHECK-NEXT:    ret13  %s = sub i64 %x, %y14  store i64 %s, ptr %p15  %ov = icmp ult i64 %x, %y16  ret i1 %ov17}18 19; Verify insertion point for single-BB. Toggle predicate.20 21define i1 @usubo_ugt_i32(i32 %x, i32 %y, ptr %p) nounwind {22; CHECK-LABEL: usubo_ugt_i32:23; CHECK:       // %bb.0:24; CHECK-NEXT:    subs w8, w0, w125; CHECK-NEXT:    cset w0, lo26; CHECK-NEXT:    str w8, [x2]27; CHECK-NEXT:    ret28  %ov = icmp ugt i32 %y, %x29  %s = sub i32 %x, %y30  store i32 %s, ptr %p31  ret i1 %ov32}33 34; Constant operand should match.35 36define i1 @usubo_ugt_constant_op0_i8(i8 %x, ptr %p) nounwind {37; CHECK-LABEL: usubo_ugt_constant_op0_i8:38; CHECK:       // %bb.0:39; CHECK-NEXT:    and w8, w0, #0xff40; CHECK-NEXT:    mov w9, #42 // =0x2a41; CHECK-NEXT:    cmp w8, #4242; CHECK-NEXT:    sub w9, w9, w043; CHECK-NEXT:    cset w8, hi44; CHECK-NEXT:    strb w9, [x1]45; CHECK-NEXT:    mov w0, w846; CHECK-NEXT:    ret47  %s = sub i8 42, %x48  %ov = icmp ugt i8 %x, 4249  store i8 %s, ptr %p50  ret i1 %ov51}52 53; Compare with constant operand 0 is canonicalized by commuting, but verify match for non-canonical form.54 55define i1 @usubo_ult_constant_op0_i16(i16 %x, ptr %p) nounwind {56; CHECK-LABEL: usubo_ult_constant_op0_i16:57; CHECK:       // %bb.0:58; CHECK-NEXT:    and w8, w0, #0xffff59; CHECK-NEXT:    mov w9, #43 // =0x2b60; CHECK-NEXT:    cmp w8, #4361; CHECK-NEXT:    sub w9, w9, w062; CHECK-NEXT:    cset w8, hi63; CHECK-NEXT:    strh w9, [x1]64; CHECK-NEXT:    mov w0, w865; CHECK-NEXT:    ret66  %s = sub i16 43, %x67  %ov = icmp ult i16 43, %x68  store i16 %s, ptr %p69  ret i1 %ov70}71 72; Subtract with constant operand 1 is canonicalized to add.73 74define i1 @usubo_ult_constant_op1_i16(i16 %x, ptr %p) nounwind {75; CHECK-LABEL: usubo_ult_constant_op1_i16:76; CHECK:       // %bb.0:77; CHECK-NEXT:    and w8, w0, #0xffff78; CHECK-NEXT:    sub w9, w0, #4479; CHECK-NEXT:    cmp w8, #4480; CHECK-NEXT:    strh w9, [x1]81; CHECK-NEXT:    cset w8, lo82; CHECK-NEXT:    mov w0, w883; CHECK-NEXT:    ret84  %s = add i16 %x, -4485  %ov = icmp ult i16 %x, 4486  store i16 %s, ptr %p87  ret i1 %ov88}89 90define i1 @usubo_ugt_constant_op1_i8(i8 %x, ptr %p) nounwind {91; CHECK-LABEL: usubo_ugt_constant_op1_i8:92; CHECK:       // %bb.0:93; CHECK-NEXT:    and w8, w0, #0xff94; CHECK-NEXT:    sub w9, w0, #4595; CHECK-NEXT:    cmp w8, #4596; CHECK-NEXT:    strb w9, [x1]97; CHECK-NEXT:    cset w8, lo98; CHECK-NEXT:    mov w0, w899; CHECK-NEXT:    ret100  %ov = icmp ugt i8 45, %x101  %s = add i8 %x, -45102  store i8 %s, ptr %p103  ret i1 %ov104}105 106; Special-case: subtract 1 changes the compare predicate and constant.107 108define i1 @usubo_eq_constant1_op1_i32(i32 %x, ptr %p) nounwind {109; CHECK-LABEL: usubo_eq_constant1_op1_i32:110; CHECK:       // %bb.0:111; CHECK-NEXT:    cmp w0, #0112; CHECK-NEXT:    sub w9, w0, #1113; CHECK-NEXT:    cset w8, eq114; CHECK-NEXT:    str w9, [x1]115; CHECK-NEXT:    mov w0, w8116; CHECK-NEXT:    ret117  %s = add i32 %x, -1118  %ov = icmp eq i32 %x, 0119  store i32 %s, ptr %p120  ret i1 %ov121}122 123; Verify insertion point for multi-BB.124 125declare void @call(i1)126 127define i1 @usubo_ult_sub_dominates_i64(i64 %x, i64 %y, ptr %p, i1 %cond) nounwind {128; CHECK-LABEL: usubo_ult_sub_dominates_i64:129; CHECK:       // %bb.0: // %entry130; CHECK-NEXT:    tbz w3, #0, .LBB7_2131; CHECK-NEXT:  // %bb.1: // %t132; CHECK-NEXT:    subs x8, x0, x1133; CHECK-NEXT:    cset w3, lo134; CHECK-NEXT:    str x8, [x2]135; CHECK-NEXT:  .LBB7_2: // %common.ret136; CHECK-NEXT:    and w0, w3, #0x1137; CHECK-NEXT:    ret138entry:139  br i1 %cond, label %t, label %f140 141t:142  %s = sub i64 %x, %y143  store i64 %s, ptr %p144  br i1 %cond, label %end, label %f145 146f:147  ret i1 %cond148 149end:150  %ov = icmp ult i64 %x, %y151  ret i1 %ov152}153 154define i1 @usubo_ult_cmp_dominates_i64(i64 %x, i64 %y, ptr %p, i1 %cond) nounwind {155; CHECK-LABEL: usubo_ult_cmp_dominates_i64:156; CHECK:       // %bb.0: // %entry157; CHECK-NEXT:    stp x30, x23, [sp, #-48]! // 16-byte Folded Spill158; CHECK-NEXT:    stp x20, x19, [sp, #32] // 16-byte Folded Spill159; CHECK-NEXT:    mov w19, w3160; CHECK-NEXT:    stp x22, x21, [sp, #16] // 16-byte Folded Spill161; CHECK-NEXT:    tbz w3, #0, .LBB8_3162; CHECK-NEXT:  // %bb.1: // %t163; CHECK-NEXT:    cmp x0, x1164; CHECK-NEXT:    mov x22, x0165; CHECK-NEXT:    mov x20, x2166; CHECK-NEXT:    cset w21, lo167; CHECK-NEXT:    mov x23, x1168; CHECK-NEXT:    mov w0, w21169; CHECK-NEXT:    bl call170; CHECK-NEXT:    subs x8, x22, x23171; CHECK-NEXT:    b.hs .LBB8_3172; CHECK-NEXT:  // %bb.2: // %end173; CHECK-NEXT:    mov w19, w21174; CHECK-NEXT:    str x8, [x20]175; CHECK-NEXT:  .LBB8_3: // %common.ret176; CHECK-NEXT:    and w0, w19, #0x1177; CHECK-NEXT:    ldp x20, x19, [sp, #32] // 16-byte Folded Reload178; CHECK-NEXT:    ldp x22, x21, [sp, #16] // 16-byte Folded Reload179; CHECK-NEXT:    ldp x30, x23, [sp], #48 // 16-byte Folded Reload180; CHECK-NEXT:    ret181entry:182  br i1 %cond, label %t, label %f183 184t:185  %ov = icmp ult i64 %x, %y186  call void @call(i1 %ov)187  br i1 %ov, label %end, label %f188 189f:190  ret i1 %cond191 192end:193  %s = sub i64 %x, %y194  store i64 %s, ptr %p195  ret i1 %ov196}197 198