Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LoongArch] Add codegen support for fabs
Differential Revision: https://reviews.llvm.org/D131871
- Loading branch information
1 parent
d1f36da
commit a9d46d9
Showing
3 changed files
with
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc --mtriple=loongarch32 --mattr=+f,-d < %s | FileCheck %s --check-prefix=LA32F | ||
; RUN: llc --mtriple=loongarch32 --mattr=+d < %s | FileCheck %s --check-prefix=LA32D | ||
; RUN: llc --mtriple=loongarch64 --mattr=+f,-d < %s | FileCheck %s --check-prefix=LA64F | ||
; RUN: llc --mtriple=loongarch64 --mattr=+d < %s | FileCheck %s --check-prefix=LA64D | ||
|
||
declare float @llvm.fabs.f32(float) | ||
declare double @llvm.fabs.f64(double) | ||
|
||
define float @fabs_f32(float %a) nounwind { | ||
; LA32F-LABEL: fabs_f32: | ||
; LA32F: # %bb.0: | ||
; LA32F-NEXT: fabs.s $fa0, $fa0 | ||
; LA32F-NEXT: ret | ||
; | ||
; LA32D-LABEL: fabs_f32: | ||
; LA32D: # %bb.0: | ||
; LA32D-NEXT: fabs.s $fa0, $fa0 | ||
; LA32D-NEXT: ret | ||
; | ||
; LA64F-LABEL: fabs_f32: | ||
; LA64F: # %bb.0: | ||
; LA64F-NEXT: fabs.s $fa0, $fa0 | ||
; LA64F-NEXT: ret | ||
; | ||
; LA64D-LABEL: fabs_f32: | ||
; LA64D: # %bb.0: | ||
; LA64D-NEXT: fabs.s $fa0, $fa0 | ||
; LA64D-NEXT: ret | ||
%1 = call float @llvm.fabs.f32(float %a) | ||
ret float %1 | ||
} | ||
|
||
define double @fabs_f64(double %a) nounwind { | ||
; LA32F-LABEL: fabs_f64: | ||
; LA32F: # %bb.0: | ||
; LA32F-NEXT: bstrpick.w $a1, $a1, 30, 0 | ||
; LA32F-NEXT: ret | ||
; | ||
; LA32D-LABEL: fabs_f64: | ||
; LA32D: # %bb.0: | ||
; LA32D-NEXT: fabs.d $fa0, $fa0 | ||
; LA32D-NEXT: ret | ||
; | ||
; LA64F-LABEL: fabs_f64: | ||
; LA64F: # %bb.0: | ||
; LA64F-NEXT: bstrpick.d $a0, $a0, 62, 0 | ||
; LA64F-NEXT: ret | ||
; | ||
; LA64D-LABEL: fabs_f64: | ||
; LA64D: # %bb.0: | ||
; LA64D-NEXT: fabs.d $fa0, $fa0 | ||
; LA64D-NEXT: ret | ||
%1 = call double @llvm.fabs.f64(double %a) | ||
ret double %1 | ||
} |