1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00

[InstCombine] Add tests for known bits for min/max intrinsics (NFC)

We already have test coverage for the underlying calculation,
this just checked that the folding is wired up...
This commit is contained in:
Nikita Popov 2020-09-08 20:57:40 +02:00
parent b3f0a94428
commit 577016c234

View File

@ -0,0 +1,59 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -instcombine < %s | FileCheck %s
declare i8 @llvm.umin.i8(i8, i8)
declare i8 @llvm.umax.i8(i8, i8)
declare i8 @llvm.smin.i8(i8, i8)
declare i8 @llvm.smax.i8(i8, i8)
define i8 @umin_known_bits(i8 %x, i8 %y) {
; CHECK-LABEL: @umin_known_bits(
; CHECK-NEXT: [[X2:%.*]] = and i8 [[X:%.*]], 127
; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[X2]], i8 [[Y:%.*]])
; CHECK-NEXT: [[R:%.*]] = and i8 [[M]], -128
; CHECK-NEXT: ret i8 [[R]]
;
%x2 = and i8 %x, 127
%m = call i8 @llvm.umin.i8(i8 %x2, i8 %y)
%r = and i8 %m, -128
ret i8 %r
}
define i8 @umax_known_bits(i8 %x, i8 %y) {
; CHECK-LABEL: @umax_known_bits(
; CHECK-NEXT: [[X2:%.*]] = or i8 [[X:%.*]], -128
; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[X2]], i8 [[Y:%.*]])
; CHECK-NEXT: [[R:%.*]] = and i8 [[M]], -128
; CHECK-NEXT: ret i8 [[R]]
;
%x2 = or i8 %x, -128
%m = call i8 @llvm.umax.i8(i8 %x2, i8 %y)
%r = and i8 %m, -128
ret i8 %r
}
define i8 @smin_known_bits(i8 %x, i8 %y) {
; CHECK-LABEL: @smin_known_bits(
; CHECK-NEXT: [[X2:%.*]] = or i8 [[X:%.*]], -128
; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[X2]], i8 [[Y:%.*]])
; CHECK-NEXT: [[R:%.*]] = and i8 [[M]], -128
; CHECK-NEXT: ret i8 [[R]]
;
%x2 = or i8 %x, -128
%m = call i8 @llvm.smin.i8(i8 %x2, i8 %y)
%r = and i8 %m, -128
ret i8 %r
}
define i8 @smax_known_bits(i8 %x, i8 %y) {
; CHECK-LABEL: @smax_known_bits(
; CHECK-NEXT: [[X2:%.*]] = and i8 [[X:%.*]], 127
; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[X2]], i8 [[Y:%.*]])
; CHECK-NEXT: [[R:%.*]] = and i8 [[M]], -128
; CHECK-NEXT: ret i8 [[R]]
;
%x2 = and i8 %x, 127
%m = call i8 @llvm.smax.i8(i8 %x2, i8 %y)
%r = and i8 %m, -128
ret i8 %r
}