1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -S < %s | FileCheck %s
3 ; RUN: opt -S -passes=instcombine < %s | FileCheck %s --check-prefix=INSTCOMBINE
5 ; llvm.umax is intentionally missing the mangling suffix here, to show that
6 ; this works fine with auto-upgrade.
7 define i16 @test(i8 %x, i8 %y) {
8 ; CHECK-LABEL: define i16 @test(
9 ; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
10 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X]], -1
11 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
12 ; CHECK-NEXT: [[MAX1:%.*]] = call i8 @llvm.umax.i8(i8 [[X]], i8 [[Y]])
13 ; CHECK-NEXT: [[X_EXT:%.*]] = zext i8 [[X]] to i16
14 ; CHECK-NEXT: [[Y_EXT:%.*]] = zext i8 [[Y]] to i16
15 ; CHECK-NEXT: [[MAX2:%.*]] = call i16 @llvm.umax.i16(i16 [[X_EXT]], i16 [[Y_EXT]])
16 ; CHECK-NEXT: ret i16 [[MAX2]]
18 ; INSTCOMBINE-LABEL: define i16 @test(
19 ; INSTCOMBINE-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
20 ; INSTCOMBINE-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X]], -1
21 ; INSTCOMBINE-NEXT: call void @llvm.assume(i1 [[CMP]])
22 ; INSTCOMBINE-NEXT: [[TMP1:%.*]] = call i8 @llvm.umax.i8(i8 [[X]], i8 [[Y]])
23 ; INSTCOMBINE-NEXT: [[MAX2:%.*]] = zext i8 [[TMP1]] to i16
24 ; INSTCOMBINE-NEXT: ret i16 [[MAX2]]
26 %cmp = icmp sgt i8 %x, -1
27 call void @llvm.assume(i1 %cmp)
28 %max1 = call i8 @llvm.umax(i8 %x, i8 %y)
29 %x.ext = zext i8 %x to i16
30 %y.ext = zext i8 %y to i16
31 %max2 = call i16 @llvm.umax.i16(i16 %x.ext, i16 %y.ext)