-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AArch64] Add some basic handling for bf16 constants.
This adds some basic handling for bf16 constants, attempting to treat them a lot like fp16 constants where it can. Zero immediates get lowered to FMOVH0, others either get lowered to FMOVWHr(MOVi32imm) or use FMOVHi if they can. Without fp16 they get expanded. This may not always be optimal, but fixes a gap in our lowering. See llvm/test/CodeGen/AArch64/f16-imm.ll for the equivalent fp16 test. Differential Revision: https://reviews.llvm.org/D156649
- Loading branch information
1 parent
e9bdf4a
commit 778fa4e
Showing
5 changed files
with
143 additions
and
4 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
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,121 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc < %s -mtriple=aarch64 -mattr=+fullfp16 | FileCheck %s --check-prefixes=CHECK,CHECK-FP16 | ||
; RUN: llc < %s -mtriple=aarch64 -mattr=-fullfp16 | FileCheck %s --check-prefixes=CHECK,CHECK-NOFP16 | ||
|
||
define bfloat @Const0() { | ||
; CHECK-LABEL: Const0: | ||
; CHECK: // %bb.0: // %entry | ||
; CHECK-NEXT: movi d0, #0000000000000000 | ||
; CHECK-NEXT: ret | ||
entry: | ||
ret bfloat 0xR0000 | ||
} | ||
|
||
define bfloat @Const1() { | ||
; CHECK-FP16-LABEL: Const1: | ||
; CHECK-FP16: // %bb.0: // %entry | ||
; CHECK-FP16-NEXT: fmov h0, #1.00000000 | ||
; CHECK-FP16-NEXT: ret | ||
; | ||
; CHECK-NOFP16-LABEL: Const1: | ||
; CHECK-NOFP16: // %bb.0: // %entry | ||
; CHECK-NOFP16-NEXT: adrp x8, .LCPI1_0 | ||
; CHECK-NOFP16-NEXT: ldr h0, [x8, :lo12:.LCPI1_0] | ||
; CHECK-NOFP16-NEXT: ret | ||
entry: | ||
ret bfloat 0xR3C00 | ||
} | ||
|
||
define bfloat @Const2() { | ||
; CHECK-FP16-LABEL: Const2: | ||
; CHECK-FP16: // %bb.0: // %entry | ||
; CHECK-FP16-NEXT: fmov h0, #0.12500000 | ||
; CHECK-FP16-NEXT: ret | ||
; | ||
; CHECK-NOFP16-LABEL: Const2: | ||
; CHECK-NOFP16: // %bb.0: // %entry | ||
; CHECK-NOFP16-NEXT: adrp x8, .LCPI2_0 | ||
; CHECK-NOFP16-NEXT: ldr h0, [x8, :lo12:.LCPI2_0] | ||
; CHECK-NOFP16-NEXT: ret | ||
entry: | ||
ret bfloat 0xR3000 | ||
} | ||
|
||
define bfloat @Const3() { | ||
; CHECK-FP16-LABEL: Const3: | ||
; CHECK-FP16: // %bb.0: // %entry | ||
; CHECK-FP16-NEXT: fmov h0, #30.00000000 | ||
; CHECK-FP16-NEXT: ret | ||
; | ||
; CHECK-NOFP16-LABEL: Const3: | ||
; CHECK-NOFP16: // %bb.0: // %entry | ||
; CHECK-NOFP16-NEXT: adrp x8, .LCPI3_0 | ||
; CHECK-NOFP16-NEXT: ldr h0, [x8, :lo12:.LCPI3_0] | ||
; CHECK-NOFP16-NEXT: ret | ||
entry: | ||
ret bfloat 0xR4F80 | ||
} | ||
|
||
define bfloat @Const4() { | ||
; CHECK-FP16-LABEL: Const4: | ||
; CHECK-FP16: // %bb.0: // %entry | ||
; CHECK-FP16-NEXT: fmov h0, #31.00000000 | ||
; CHECK-FP16-NEXT: ret | ||
; | ||
; CHECK-NOFP16-LABEL: Const4: | ||
; CHECK-NOFP16: // %bb.0: // %entry | ||
; CHECK-NOFP16-NEXT: adrp x8, .LCPI4_0 | ||
; CHECK-NOFP16-NEXT: ldr h0, [x8, :lo12:.LCPI4_0] | ||
; CHECK-NOFP16-NEXT: ret | ||
entry: | ||
ret bfloat 0xR4FC0 | ||
} | ||
|
||
define bfloat @Const5() { | ||
; CHECK-FP16-LABEL: Const5: | ||
; CHECK-FP16: // %bb.0: // %entry | ||
; CHECK-FP16-NEXT: mov w8, #12272 // =0x2ff0 | ||
; CHECK-FP16-NEXT: fmov h0, w8 | ||
; CHECK-FP16-NEXT: ret | ||
; | ||
; CHECK-NOFP16-LABEL: Const5: | ||
; CHECK-NOFP16: // %bb.0: // %entry | ||
; CHECK-NOFP16-NEXT: adrp x8, .LCPI5_0 | ||
; CHECK-NOFP16-NEXT: ldr h0, [x8, :lo12:.LCPI5_0] | ||
; CHECK-NOFP16-NEXT: ret | ||
entry: | ||
ret bfloat 0xR2FF0 | ||
} | ||
|
||
define bfloat @Const6() { | ||
; CHECK-FP16-LABEL: Const6: | ||
; CHECK-FP16: // %bb.0: // %entry | ||
; CHECK-FP16-NEXT: mov w8, #20417 // =0x4fc1 | ||
; CHECK-FP16-NEXT: fmov h0, w8 | ||
; CHECK-FP16-NEXT: ret | ||
; | ||
; CHECK-NOFP16-LABEL: Const6: | ||
; CHECK-NOFP16: // %bb.0: // %entry | ||
; CHECK-NOFP16-NEXT: adrp x8, .LCPI6_0 | ||
; CHECK-NOFP16-NEXT: ldr h0, [x8, :lo12:.LCPI6_0] | ||
; CHECK-NOFP16-NEXT: ret | ||
entry: | ||
ret bfloat 0xR4FC1 | ||
} | ||
|
||
define bfloat @Const7() { | ||
; CHECK-FP16-LABEL: Const7: | ||
; CHECK-FP16: // %bb.0: // %entry | ||
; CHECK-FP16-NEXT: mov w8, #20480 // =0x5000 | ||
; CHECK-FP16-NEXT: fmov h0, w8 | ||
; CHECK-FP16-NEXT: ret | ||
; | ||
; CHECK-NOFP16-LABEL: Const7: | ||
; CHECK-NOFP16: // %bb.0: // %entry | ||
; CHECK-NOFP16-NEXT: adrp x8, .LCPI7_0 | ||
; CHECK-NOFP16-NEXT: ldr h0, [x8, :lo12:.LCPI7_0] | ||
; CHECK-NOFP16-NEXT: ret | ||
entry: | ||
ret bfloat 0xR5000 | ||
} | ||
|