1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -codegenprepare -S -mtriple=riscv64 < %s | FileCheck %s
4 define i8 @hoist_add(i8 %x) {
5 ; CHECK-LABEL: define i8 @hoist_add(
6 ; CHECK-SAME: i8 [[X:%.*]]) {
8 ; CHECK-NEXT: [[INC:%.*]] = add i8 [[X]], 1
9 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i8 [[INC]], 0
10 ; CHECK-NEXT: br i1 [[TMP0]], label [[EXIT:%.*]], label [[IF_THEN:%.*]]
12 ; CHECK-NEXT: br label [[EXIT]]
14 ; CHECK-NEXT: [[RETVAL:%.*]] = phi i8 [ [[INC]], [[IF_THEN]] ], [ -1, [[ENTRY:%.*]] ]
15 ; CHECK-NEXT: ret i8 [[RETVAL]]
18 %cmp = icmp eq i8 %x, -1
19 br i1 %cmp, label %exit, label %if.then
22 %inc = add nuw nsw i8 %x, 1
26 %retval = phi i8 [ %inc, %if.then ], [ -1, %entry ]
30 define i8 @hoist_lshr(i8 %x) {
31 ; CHECK-LABEL: define i8 @hoist_lshr(
32 ; CHECK-SAME: i8 [[X:%.*]]) {
34 ; CHECK-NEXT: [[INC:%.*]] = lshr i8 [[X]], 3
35 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i8 [[INC]], 0
36 ; CHECK-NEXT: br i1 [[TMP0]], label [[EXIT:%.*]], label [[IF_THEN:%.*]]
38 ; CHECK-NEXT: br label [[EXIT]]
40 ; CHECK-NEXT: [[RETVAL:%.*]] = phi i8 [ [[INC]], [[IF_THEN]] ], [ -1, [[ENTRY:%.*]] ]
41 ; CHECK-NEXT: ret i8 [[RETVAL]]
44 %cmp = icmp ult i8 %x, 8
45 br i1 %cmp, label %exit, label %if.then
48 %inc = lshr exact i8 %x, 3
52 %retval = phi i8 [ %inc, %if.then ], [ -1, %entry ]
56 define i8 @nomove_add(i8 %x) {
57 ; CHECK-LABEL: define i8 @nomove_add(
58 ; CHECK-SAME: i8 [[X:%.*]]) {
60 ; CHECK-NEXT: [[INC:%.*]] = add i8 [[X]], 1
61 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i8 [[INC]], 0
62 ; CHECK-NEXT: br i1 [[TMP0]], label [[EXIT:%.*]], label [[IF_THEN:%.*]]
64 ; CHECK-NEXT: br label [[EXIT]]
66 ; CHECK-NEXT: [[RETVAL:%.*]] = phi i8 [ [[INC]], [[IF_THEN]] ], [ -1, [[ENTRY:%.*]] ]
67 ; CHECK-NEXT: ret i8 [[RETVAL]]
70 %inc = add nuw nsw i8 %x, 1
71 %cmp = icmp eq i8 %x, -1
72 br i1 %cmp, label %exit, label %if.then
78 %retval = phi i8 [ %inc, %if.then ], [ -1, %entry ]