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: slli a2, a2, 32
14 ; CHECK-NEXT: srli a2, a2, 32
15 ; CHECK-NEXT: sub a1, a1, a0
16 ; CHECK-NEXT: addi a1, a1, -2
17 ; CHECK-NEXT: slli a1, a1, 32
18 ; CHECK-NEXT: srli a1, a1, 32
19 ; CHECK-NEXT: mul a1, a2, a1
20 ; CHECK-NEXT: srli a1, a1, 1
21 ; CHECK-NEXT: add a0, a3, a0
22 ; CHECK-NEXT: addw a0, a0, a1
24 ; CHECK-NEXT: .LBB0_2:
25 ; CHECK-NEXT: mv a0, zero
28 %cmp6 = icmp slt i32 %s, %n
29 br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup
31 for.body.preheader: ; preds = %entry
36 %4 = zext i32 %1 to i33
39 %7 = zext i32 %6 to i33
42 %10 = trunc i33 %9 to i32
44 %12 = add i32 %11, %10
45 br label %for.cond.cleanup
47 for.cond.cleanup: ; preds = %for.body.preheader, %entry
48 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %12, %for.body.preheader ]
52 define signext i32 @subw(i32 signext %s, i32 signext %n, i32 signext %k) nounwind {
54 ; CHECK: # %bb.0: # %entry
55 ; CHECK-NEXT: bge a0, a1, .LBB1_2
56 ; CHECK-NEXT: # %bb.1: # %for.body.preheader
57 ; CHECK-NEXT: not a2, a0
58 ; CHECK-NEXT: add a3, a2, a1
59 ; CHECK-NEXT: mul a2, a3, a2
60 ; CHECK-NEXT: slli a3, a3, 32
61 ; CHECK-NEXT: srli a3, a3, 32
62 ; CHECK-NEXT: sub a1, a1, a0
63 ; CHECK-NEXT: addi a1, a1, -2
64 ; CHECK-NEXT: slli a1, a1, 32
65 ; CHECK-NEXT: srli a1, a1, 32
66 ; CHECK-NEXT: mul a1, a3, a1
67 ; CHECK-NEXT: srli a1, a1, 1
68 ; CHECK-NEXT: sub a0, a2, a0
69 ; CHECK-NEXT: subw a0, a0, a1
71 ; CHECK-NEXT: .LBB1_2:
72 ; CHECK-NEXT: mv a0, zero
75 %cmp6 = icmp slt i32 %s, %n
76 br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup
78 for.body.preheader: ; preds = %entry
83 %4 = zext i32 %1 to i33
86 %7 = zext i32 %6 to i33
89 %10 = trunc i33 %9 to i32
91 %12 = sub i32 %11, %10
92 br label %for.cond.cleanup
94 for.cond.cleanup: ; preds = %for.body.preheader, %entry
95 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %12, %for.body.preheader ]