1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00
llvm-mirror/test/CodeGen/X86/mulfix_combine.ll
Bjorn Pettersson f8a47e6d1e [Intrinsic] Add the llvm.umul.fix.sat intrinsic
Summary:
Add an intrinsic that takes 2 unsigned integers with
the scale of them provided as the third argument and
performs fixed point multiplication on them. The
result is saturated and clamped between the largest and
smallest representable values of the first 2 operands.

This is a part of implementing fixed point arithmetic
in clang where some of the more complex operations
will be implemented as intrinsics.

Patch by: leonardchan, bjope

Reviewers: RKSimon, craig.topper, bevinh, leonardchan, lebedev.ri, spatel

Reviewed By: leonardchan

Subscribers: ychen, wuzish, nemanjai, MaskRay, jsji, jdoerfert, Ka-Ka, hiraditya, rjmccall, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57836

llvm-svn: 371308
2019-09-07 12:16:14 +00:00

157 lines
4.8 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-linux -o - | FileCheck %s
declare i32 @llvm.smul.fix.i32(i32, i32, i32 immarg)
declare i32 @llvm.umul.fix.i32(i32, i32, i32 immarg)
declare i32 @llvm.smul.fix.sat.i32(i32, i32, i32 immarg)
declare i32 @llvm.umul.fix.sat.i32(i32, i32, i32 immarg)
declare <4 x i32> @llvm.smul.fix.v4i32(<4 x i32>, <4 x i32>, i32 immarg)
declare <4 x i32> @llvm.umul.fix.v4i32(<4 x i32>, <4 x i32>, i32 immarg)
declare <4 x i32> @llvm.smul.fix.sat.v4i32(<4 x i32>, <4 x i32>, i32 immarg)
declare <4 x i32> @llvm.umul.fix.sat.v4i32(<4 x i32>, <4 x i32>, i32 immarg)
define i32 @smulfix_undef(i32 %y) nounwind {
; CHECK-LABEL: smulfix_undef:
; CHECK: # %bb.0:
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: retq
%tmp = call i32 @llvm.smul.fix.i32(i32 undef, i32 %y, i32 2)
ret i32 %tmp
}
define i32 @smulfix_zero(i32 %y) nounwind {
; CHECK-LABEL: smulfix_zero:
; CHECK: # %bb.0:
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: retq
%tmp = call i32 @llvm.smul.fix.i32(i32 0, i32 %y, i32 2)
ret i32 %tmp
}
define i32 @umulfix_undef(i32 %y) nounwind {
; CHECK-LABEL: umulfix_undef:
; CHECK: # %bb.0:
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: retq
%tmp = call i32 @llvm.umul.fix.i32(i32 undef, i32 %y, i32 2)
ret i32 %tmp
}
define i32 @umulfix_zero(i32 %y) nounwind {
; CHECK-LABEL: umulfix_zero:
; CHECK: # %bb.0:
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: retq
%tmp = call i32 @llvm.umul.fix.i32(i32 0, i32 %y, i32 2)
ret i32 %tmp
}
define i32 @smulfixsat_undef(i32 %y) nounwind {
; CHECK-LABEL: smulfixsat_undef:
; CHECK: # %bb.0:
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: retq
%tmp = call i32 @llvm.smul.fix.sat.i32(i32 undef, i32 %y, i32 2)
ret i32 %tmp
}
define i32 @smulfixsat_zero(i32 %y) nounwind {
; CHECK-LABEL: smulfixsat_zero:
; CHECK: # %bb.0:
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: retq
%tmp = call i32 @llvm.smul.fix.sat.i32(i32 0, i32 %y, i32 2)
ret i32 %tmp
}
define i32 @umulfixsat_undef(i32 %y) nounwind {
; CHECK-LABEL: umulfixsat_undef:
; CHECK: # %bb.0:
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: retq
%tmp = call i32 @llvm.umul.fix.sat.i32(i32 undef, i32 %y, i32 2)
ret i32 %tmp
}
define i32 @umulfixsat_zero(i32 %y) nounwind {
; CHECK-LABEL: umulfixsat_zero:
; CHECK: # %bb.0:
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: retq
%tmp = call i32 @llvm.umul.fix.sat.i32(i32 0, i32 %y, i32 2)
ret i32 %tmp
}
define <4 x i32> @vec_smulfix_undef(<4 x i32> %y) nounwind {
; CHECK-LABEL: vec_smulfix_undef:
; CHECK: # %bb.0:
; CHECK-NEXT: xorps %xmm0, %xmm0
; CHECK-NEXT: retq
%tmp = call <4 x i32> @llvm.smul.fix.v4i32(<4 x i32> undef, <4 x i32> %y, i32 2)
ret <4 x i32> %tmp
}
define <4 x i32> @vec_smulfix_zero(<4 x i32> %y) nounwind {
; CHECK-LABEL: vec_smulfix_zero:
; CHECK: # %bb.0:
; CHECK-NEXT: xorps %xmm0, %xmm0
; CHECK-NEXT: retq
%tmp = call <4 x i32> @llvm.smul.fix.v4i32(<4 x i32> <i32 0, i32 0, i32 0, i32 0>, <4 x i32> %y, i32 2)
ret <4 x i32> %tmp
}
define <4 x i32> @vec_umulfix_undef(<4 x i32> %y) nounwind {
; CHECK-LABEL: vec_umulfix_undef:
; CHECK: # %bb.0:
; CHECK-NEXT: xorps %xmm0, %xmm0
; CHECK-NEXT: retq
%tmp = call <4 x i32> @llvm.umul.fix.v4i32(<4 x i32> undef, <4 x i32> %y, i32 2)
ret <4 x i32> %tmp
}
define <4 x i32> @vec_umulfix_zero(<4 x i32> %y) nounwind {
; CHECK-LABEL: vec_umulfix_zero:
; CHECK: # %bb.0:
; CHECK-NEXT: xorps %xmm0, %xmm0
; CHECK-NEXT: retq
%tmp = call <4 x i32> @llvm.umul.fix.v4i32(<4 x i32> <i32 0, i32 0, i32 0, i32 0>, <4 x i32> %y, i32 2)
ret <4 x i32> %tmp
}
define <4 x i32> @vec_smulfixsat_undef(<4 x i32> %y) nounwind {
; CHECK-LABEL: vec_smulfixsat_undef:
; CHECK: # %bb.0:
; CHECK-NEXT: xorps %xmm0, %xmm0
; CHECK-NEXT: retq
%tmp = call <4 x i32> @llvm.smul.fix.sat.v4i32(<4 x i32> undef, <4 x i32> %y, i32 2)
ret <4 x i32> %tmp
}
define <4 x i32> @vec_smulfixsat_zero(<4 x i32> %y) nounwind {
; CHECK-LABEL: vec_smulfixsat_zero:
; CHECK: # %bb.0:
; CHECK-NEXT: xorps %xmm0, %xmm0
; CHECK-NEXT: retq
%tmp = call <4 x i32> @llvm.smul.fix.sat.v4i32(<4 x i32> <i32 0, i32 0, i32 0, i32 0>, <4 x i32> %y, i32 2)
ret <4 x i32> %tmp
}
define <4 x i32> @vec_umulfixsat_undef(<4 x i32> %y) nounwind {
; CHECK-LABEL: vec_umulfixsat_undef:
; CHECK: # %bb.0:
; CHECK-NEXT: xorps %xmm0, %xmm0
; CHECK-NEXT: retq
%tmp = call <4 x i32> @llvm.umul.fix.sat.v4i32(<4 x i32> undef, <4 x i32> %y, i32 2)
ret <4 x i32> %tmp
}
define <4 x i32> @vec_umulfixsat_zero(<4 x i32> %y) nounwind {
; CHECK-LABEL: vec_umulfixsat_zero:
; CHECK: # %bb.0:
; CHECK-NEXT: xorps %xmm0, %xmm0
; CHECK-NEXT: retq
%tmp = call <4 x i32> @llvm.umul.fix.sat.v4i32(<4 x i32> <i32 0, i32 0, i32 0, i32 0>, <4 x i32> %y, i32 2)
ret <4 x i32> %tmp
}