1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -mattr=+m -verify-machineinstrs < %s | FileCheck %s
4 define signext i32 @addw(i32 signext %s, i32 signext %n, i32 signext %k) nounwind {
6 ; CHECK: # %bb.0: # %entry
7 ; CHECK-NEXT: bge a0, a1, .LBB0_2
8 ; CHECK-NEXT: # %bb.1: # %for.body.preheader
9 ; CHECK-NEXT: not a2, a0
10 ; CHECK-NEXT: add a2, a2, a1
11 ; CHECK-NEXT: addi a3, a0, 1
12 ; CHECK-NEXT: mul a3, a2, a3
13 ; CHECK-NEXT: subw a1, a1, a0
14 ; CHECK-NEXT: addi a1, a1, -2
15 ; CHECK-NEXT: slli a1, a1, 32
16 ; CHECK-NEXT: slli a2, a2, 32
17 ; CHECK-NEXT: mulhu a1, a2, a1
18 ; CHECK-NEXT: srli a1, a1, 1
19 ; CHECK-NEXT: add a0, a3, a0
20 ; CHECK-NEXT: addw a0, a0, a1
22 ; CHECK-NEXT: .LBB0_2:
23 ; CHECK-NEXT: li a0, 0
26 %cmp6 = icmp slt i32 %s, %n
27 br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup
29 for.body.preheader: ; preds = %entry
34 %4 = zext i32 %1 to i33
37 %7 = zext i32 %6 to i33
40 %10 = trunc i33 %9 to i32
42 %12 = add i32 %11, %10
43 br label %for.cond.cleanup
45 for.cond.cleanup: ; preds = %for.body.preheader, %entry
46 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %12, %for.body.preheader ]
50 define signext i32 @subw(i32 signext %s, i32 signext %n, i32 signext %k) nounwind {
52 ; CHECK: # %bb.0: # %entry
53 ; CHECK-NEXT: bge a0, a1, .LBB1_2
54 ; CHECK-NEXT: # %bb.1: # %for.body.preheader
55 ; CHECK-NEXT: not a2, a0
56 ; CHECK-NEXT: add a3, a2, a1
57 ; CHECK-NEXT: mul a2, a3, a2
58 ; CHECK-NEXT: subw a1, a1, a0
59 ; CHECK-NEXT: addi a1, a1, -2
60 ; CHECK-NEXT: slli a1, a1, 32
61 ; CHECK-NEXT: slli a3, a3, 32
62 ; CHECK-NEXT: mulhu a1, a3, a1
63 ; CHECK-NEXT: srli a1, a1, 1
64 ; CHECK-NEXT: subw a0, a2, a0
65 ; CHECK-NEXT: subw a0, a0, a1
67 ; CHECK-NEXT: .LBB1_2:
68 ; CHECK-NEXT: li a0, 0
71 %cmp6 = icmp slt i32 %s, %n
72 br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup
74 for.body.preheader: ; preds = %entry
79 %4 = zext i32 %1 to i33
82 %7 = zext i32 %6 to i33
85 %10 = trunc i33 %9 to i32
87 %12 = sub i32 %11, %10
88 br label %for.cond.cleanup
90 for.cond.cleanup: ; preds = %for.body.preheader, %entry
91 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %12, %for.body.preheader ]