|
| 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 |
| 3 | + |
| 4 | +define i8 @hoist_add(i8 %x) { |
| 5 | +; CHECK-LABEL: define i8 @hoist_add( |
| 6 | +; CHECK-SAME: i8 [[X:%.*]]) { |
| 7 | +; CHECK-NEXT: entry: |
| 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:%.*]] |
| 11 | +; CHECK: if.then: |
| 12 | +; CHECK-NEXT: br label [[EXIT]] |
| 13 | +; CHECK: exit: |
| 14 | +; CHECK-NEXT: [[RETVAL:%.*]] = phi i8 [ [[INC]], [[IF_THEN]] ], [ -1, [[ENTRY:%.*]] ] |
| 15 | +; CHECK-NEXT: ret i8 [[RETVAL]] |
| 16 | +; |
| 17 | +entry: |
| 18 | + %cmp = icmp eq i8 %x, -1 |
| 19 | + br i1 %cmp, label %exit, label %if.then |
| 20 | + |
| 21 | +if.then: |
| 22 | + %inc = add nuw nsw i8 %x, 1 |
| 23 | + br label %exit |
| 24 | + |
| 25 | +exit: |
| 26 | + %retval = phi i8 [ %inc, %if.then ], [ -1, %entry ] |
| 27 | + ret i8 %retval |
| 28 | +} |
| 29 | + |
| 30 | +define i8 @hoist_lshr(i8 %x) { |
| 31 | +; CHECK-LABEL: define i8 @hoist_lshr( |
| 32 | +; CHECK-SAME: i8 [[X:%.*]]) { |
| 33 | +; CHECK-NEXT: entry: |
| 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:%.*]] |
| 37 | +; CHECK: if.then: |
| 38 | +; CHECK-NEXT: br label [[EXIT]] |
| 39 | +; CHECK: exit: |
| 40 | +; CHECK-NEXT: [[RETVAL:%.*]] = phi i8 [ [[INC]], [[IF_THEN]] ], [ -1, [[ENTRY:%.*]] ] |
| 41 | +; CHECK-NEXT: ret i8 [[RETVAL]] |
| 42 | +; |
| 43 | +entry: |
| 44 | + %cmp = icmp ult i8 %x, 8 |
| 45 | + br i1 %cmp, label %exit, label %if.then |
| 46 | + |
| 47 | +if.then: |
| 48 | + %inc = lshr exact i8 %x, 3 |
| 49 | + br label %exit |
| 50 | + |
| 51 | +exit: |
| 52 | + %retval = phi i8 [ %inc, %if.then ], [ -1, %entry ] |
| 53 | + ret i8 %retval |
| 54 | +} |
| 55 | + |
| 56 | +define i8 @nomove_add(i8 %x) { |
| 57 | +; CHECK-LABEL: define i8 @nomove_add( |
| 58 | +; CHECK-SAME: i8 [[X:%.*]]) { |
| 59 | +; CHECK-NEXT: entry: |
| 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:%.*]] |
| 63 | +; CHECK: if.then: |
| 64 | +; CHECK-NEXT: br label [[EXIT]] |
| 65 | +; CHECK: exit: |
| 66 | +; CHECK-NEXT: [[RETVAL:%.*]] = phi i8 [ [[INC]], [[IF_THEN]] ], [ -1, [[ENTRY:%.*]] ] |
| 67 | +; CHECK-NEXT: ret i8 [[RETVAL]] |
| 68 | +; |
| 69 | +entry: |
| 70 | + %inc = add nuw nsw i8 %x, 1 |
| 71 | + %cmp = icmp eq i8 %x, -1 |
| 72 | + br i1 %cmp, label %exit, label %if.then |
| 73 | + |
| 74 | +if.then: |
| 75 | + br label %exit |
| 76 | + |
| 77 | +exit: |
| 78 | + %retval = phi i8 [ %inc, %if.then ], [ -1, %entry ] |
| 79 | + ret i8 %retval |
| 80 | +} |
0 commit comments