mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
f8a47e6d1e
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
37 lines
1.0 KiB
LLVM
37 lines
1.0 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc < %s -mtriple=ppc32 | FileCheck %s
|
|
|
|
declare i32 @llvm.umul.fix.sat.i32(i32, i32, i32)
|
|
|
|
define i32 @func1(i32 %x, i32 %y) nounwind {
|
|
; CHECK-LABEL: func1:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: li 5, -1
|
|
; CHECK-NEXT: mulhwu. 6, 3, 4
|
|
; CHECK-NEXT: mullw 3, 3, 4
|
|
; CHECK-NEXT: bclr 12, 2, 0
|
|
; CHECK-NEXT: # %bb.1:
|
|
; CHECK-NEXT: ori 3, 5, 0
|
|
; CHECK-NEXT: blr
|
|
%tmp = call i32 @llvm.umul.fix.sat.i32(i32 %x, i32 %y, i32 0)
|
|
ret i32 %tmp
|
|
}
|
|
|
|
define i32 @func2(i32 %x, i32 %y) nounwind {
|
|
; CHECK-LABEL: func2:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: mulhwu 6, 3, 4
|
|
; CHECK-NEXT: li 5, -1
|
|
; CHECK-NEXT: cmplwi 6, 1
|
|
; CHECK-NEXT: mullw 3, 3, 4
|
|
; CHECK-NEXT: rotlwi 3, 3, 31
|
|
; CHECK-NEXT: rlwimi 3, 6, 31, 0, 0
|
|
; CHECK-NEXT: bc 12, 1, .LBB1_1
|
|
; CHECK-NEXT: blr
|
|
; CHECK-NEXT: .LBB1_1:
|
|
; CHECK-NEXT: addi 3, 5, 0
|
|
; CHECK-NEXT: blr
|
|
%tmp = call i32 @llvm.umul.fix.sat.i32(i32 %x, i32 %y, i32 1)
|
|
ret i32 %tmp
|
|
}
|