Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PowerPC] Add the support for __builtin_setrnd()
Summary: PowerPC64/PowerPC64le supports the builtin function __builtin_setrnd to set the floating point rounding mode. This function will use the least significant two bits of integer argument to set the floating point rounding mode. double __builtin_setrnd(int mode); The effective values for mode are: 0 - round to nearest 1 - round to zero 2 - round to +infinity 3 - round to -infinity Note that the mode argument will modulo 4, so if the int argument is greater than 3, it will only use the least significant two bits of the mode. Namely, builtin_setrnd(102)) is equal to builtin_setrnd(2). Reviewed By: jsji Differential Revision: https://reviews.llvm.org/D59405 llvm-svn: 357241
- Loading branch information
1 parent
711bea9
commit 05f78b3
Showing
4 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
; RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-linux-gnu < %s \ | ||
; RUN: -verify-machineinstrs | FileCheck %s | ||
; RUN: llc -mcpu=pwr7 -mtriple=powerpc64le-unknown-linux-gnu < %s \ | ||
; RUN: -verify-machineinstrs | FileCheck -check-prefix=CHECK-PWR7 %s | ||
|
||
define double @test_setrndi() { | ||
entry: | ||
%0 = tail call double @llvm.ppc.setrnd(i32 2) | ||
ret double %0 | ||
|
||
; CHECK-LABEL: @test_setrndi | ||
; CHECK: # %bb.0: | ||
; CHECK-DAG: mffs 1 | ||
; CHECK-DAG: mtfsb0 31 | ||
; CHECK-DAG: mtfsb1 30 | ||
; CHECK: blr | ||
} | ||
|
||
define double @test_setrnd(i32 signext %x) { | ||
entry: | ||
%0 = tail call double @llvm.ppc.setrnd(i32 %x) | ||
ret double %0 | ||
|
||
; CHECK-LABEL: @test_setrnd | ||
; CHECK: # %bb.0: | ||
; CHECK-DAG: mffs 1 | ||
; CHECK-DAG: mffprd [[REG1:[0-9]+]], 1 | ||
; CHECK-DAG: rldimi [[REG1]], 3, 0, 62 | ||
; CHECK-DAG: mtvsrd [[REG2:[0-9]+]], [[REG1]] | ||
; CHECK-DAG: mtfsf 255, [[REG2]] | ||
; CHECK: blr | ||
|
||
; CHECK-PWR7-LABEL: @test_setrnd | ||
; CHECK-PWR7: # %bb.0: | ||
; CHECK-PWR7-DAG: mffs 1 | ||
; CHECK-PWR7-DAG: stfd 1, -8(1) | ||
; CHECK-PWR7-DAG: ld [[REG1:[0-9]+]], -8(1) | ||
; CHECK-PWR7-DAG: rldimi [[REG1]], 3, 0, 62 | ||
; CHECK-PWR7-DAG: std [[REG1]], -16(1) | ||
; CHECK-PWR7-DAG: lfd [[REG2:[0-9]+]], -16(1) | ||
; CHECK-PWR7-DAG: mtfsf 255, [[REG2]] | ||
; CHECK-PWR7: blr | ||
} | ||
|
||
declare double @llvm.ppc.setrnd(i32) | ||
|