|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt < %s -passes=instcombine -S | FileCheck %s |
| 3 | +define void @test_as_arg(i8 %a, i8 %b) { |
| 4 | +; CHECK-LABEL: define void @test_as_arg( |
| 5 | +; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]]) { |
| 6 | +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[A]], [[B]] |
| 7 | +; CHECK-NEXT: br i1 [[CMP]], label %[[COND_END:.*]], label %[[COND_FALSE:.*]] |
| 8 | +; CHECK: [[COND_FALSE]]: |
| 9 | +; CHECK-NEXT: [[SUB:%.*]] = sub nsw i8 [[B]], [[A]] |
| 10 | +; CHECK-NEXT: [[CONV:%.*]] = sext i8 [[SUB]] to i16 |
| 11 | +; CHECK-NEXT: call void @subroutine(i16 [[CONV]]) |
| 12 | +; CHECK-NEXT: br label %[[COND_END]] |
| 13 | +; CHECK: [[COND_END]]: |
| 14 | +; CHECK-NEXT: ret void |
| 15 | +; |
| 16 | + %cmp = icmp sgt i8 %a, %b |
| 17 | + br i1 %cmp, label %cond.end, label %cond.false |
| 18 | + |
| 19 | +cond.false: |
| 20 | + %sub = sub nsw i8 %b, %a |
| 21 | + %conv = sext i8 %sub to i16 |
| 22 | + call void @subroutine(i16 %conv) |
| 23 | + br label %cond.end |
| 24 | + |
| 25 | +cond.end: |
| 26 | + ret void |
| 27 | +} |
| 28 | + |
| 29 | +declare void @subroutine(i16) |
| 30 | + |
| 31 | +define i16 @test_as_retval(i8 %a, i8 %b) { |
| 32 | +; CHECK-LABEL: define i16 @test_as_retval( |
| 33 | +; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]]) { |
| 34 | +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[A]], [[B]] |
| 35 | +; CHECK-NEXT: br i1 [[CMP]], label %[[COND_TRUE:.*]], label %[[COND_FALSE:.*]] |
| 36 | +; CHECK: [[COND_TRUE]]: |
| 37 | +; CHECK-NEXT: ret i16 0 |
| 38 | +; CHECK: [[COND_FALSE]]: |
| 39 | +; CHECK-NEXT: [[SUB:%.*]] = sub nsw i8 [[B]], [[A]] |
| 40 | +; CHECK-NEXT: [[CONV:%.*]] = sext i8 [[SUB]] to i16 |
| 41 | +; CHECK-NEXT: ret i16 [[CONV]] |
| 42 | +; |
| 43 | + %cmp = icmp sgt i8 %a, %b |
| 44 | + br i1 %cmp, label %cond.true, label %cond.false |
| 45 | + |
| 46 | +cond.true: |
| 47 | + ret i16 0 |
| 48 | + |
| 49 | +cond.false: |
| 50 | + %sub = sub nsw i8 %b, %a |
| 51 | + %conv = sext i8 %sub to i16 |
| 52 | + ret i16 %conv |
| 53 | +} |
0 commit comments