[AArch64][GlobalISel] Add better basic legalization for llround. (#168427)
This adds handling for f16 and f128 lround/llround under LP64 targets, promoting the f16 where needed and using a libcall for f128. This codegen is now identical to the selection dag version.
This commit is contained in:
parent
76dac58c9a
commit
4ecfaa602f
@ -3439,6 +3439,18 @@ LegalizerHelper::widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy) {
|
||||
Observer.changedInstr(MI);
|
||||
return Legalized;
|
||||
}
|
||||
case TargetOpcode::G_LROUND:
|
||||
case TargetOpcode::G_LLROUND:
|
||||
Observer.changingInstr(MI);
|
||||
|
||||
if (TypeIdx == 0)
|
||||
widenScalarDst(MI, WideTy);
|
||||
else
|
||||
widenScalarSrc(MI, WideTy, 1, TargetOpcode::G_FPEXT);
|
||||
|
||||
Observer.changedInstr(MI);
|
||||
return Legalized;
|
||||
|
||||
case TargetOpcode::G_INTTOPTR:
|
||||
if (TypeIdx != 1)
|
||||
return UnableToLegalize;
|
||||
|
||||
@ -449,10 +449,12 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
|
||||
.minScalar(0, s32)
|
||||
.libcallFor({{s32, s32}, {s64, s32}, {s128, s32}});
|
||||
|
||||
// TODO: Libcall support for s128.
|
||||
// TODO: s16 should be legal with full FP16 support.
|
||||
getActionDefinitionsBuilder({G_LROUND, G_LLROUND})
|
||||
.legalFor({{s64, s32}, {s64, s64}});
|
||||
.legalFor({{s64, s32}, {s64, s64}})
|
||||
.legalFor(HasFP16, {{s64, s16}})
|
||||
.minScalar(0, s64)
|
||||
.minScalar(1, s32)
|
||||
.libcallFor({{s64, s128}});
|
||||
|
||||
// TODO: Custom legalization for mismatched types.
|
||||
getActionDefinitionsBuilder(G_FCOPYSIGN)
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
|
||||
; RUN: llc < %s -mtriple=aarch64 | FileCheck %s --check-prefixes=CHECK-NOFP16
|
||||
; RUN: llc < %s -mtriple=aarch64 -mattr=+fullfp16 | FileCheck %s --check-prefixes=CHECK-FP16
|
||||
; RUN: llc < %s -mtriple=aarch64 -global-isel -global-isel-abort=2 2>&1 | FileCheck %s --check-prefixes=CHECK-NOFP16,CHECK-GI
|
||||
; RUN: llc < %s -mtriple=aarch64 -mattr=+fullfp16 -global-isel -global-isel-abort=2 2>&1 | FileCheck %s --check-prefixes=CHECK-FP16,CHECK-GI
|
||||
|
||||
; CHECK-GI: warning: Instruction selection used fallback path for testmhhs
|
||||
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for testmhws
|
||||
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for testmhxs
|
||||
; RUN: llc < %s -mtriple=aarch64 -global-isel | FileCheck %s --check-prefixes=CHECK-NOFP16
|
||||
; RUN: llc < %s -mtriple=aarch64 -mattr=+fullfp16 -global-isel | FileCheck %s --check-prefixes=CHECK-FP16
|
||||
|
||||
define i16 @testmhhs(half %x) {
|
||||
; CHECK-NOFP16-LABEL: testmhhs:
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
|
||||
; RUN: llc < %s -mtriple=aarch64 -mattr=+neon | FileCheck %s
|
||||
; RUN: llc < %s -mtriple=aarch64 -mattr=+neon -global-isel -global-isel-abort=2 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI
|
||||
|
||||
; CHECK-GI: warning: Instruction selection used fallback path for testmswl
|
||||
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for testmsll
|
||||
; RUN: llc < %s -mtriple=aarch64 -mattr=+neon -global-isel | FileCheck %s
|
||||
|
||||
define i32 @testmsws(float %x) {
|
||||
; CHECK-LABEL: testmsws:
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
|
||||
; RUN: llc < %s -mtriple=aarch64 | FileCheck %s --check-prefixes=CHECK-NOFP16
|
||||
; RUN: llc < %s -mtriple=aarch64 -mattr=+fullfp16 | FileCheck %s --check-prefixes=CHECK-FP16
|
||||
; RUN: llc < %s -mtriple=aarch64 -global-isel -global-isel-abort=2 2>&1 | FileCheck %s --check-prefixes=CHECK-NOFP16,CHECK-GI
|
||||
; RUN: llc < %s -mtriple=aarch64 -mattr=+fullfp16 -global-isel -global-isel-abort=2 2>&1 | FileCheck %s --check-prefixes=CHECK-FP16,CHECK-GI
|
||||
|
||||
; CHECK-GI: warning: Instruction selection used fallback path for testmhhs
|
||||
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for testmhws
|
||||
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for testmhxs
|
||||
; RUN: llc < %s -mtriple=aarch64 -global-isel | FileCheck %s --check-prefixes=CHECK-NOFP16
|
||||
; RUN: llc < %s -mtriple=aarch64 -mattr=+fullfp16 -global-isel | FileCheck %s --check-prefixes=CHECK-FP16
|
||||
|
||||
define i16 @testmhhs(half %x) {
|
||||
; CHECK-NOFP16-LABEL: testmhhs:
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
|
||||
; RUN: llc < %s -mtriple=aarch64 -mattr=+neon | FileCheck %s
|
||||
; RUN: llc < %s -mtriple=aarch64 -mattr=+neon -global-isel -global-isel-abort=2 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI
|
||||
|
||||
; CHECK-GI: warning: Instruction selection used fallback path for testmswl
|
||||
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for testmsll
|
||||
; RUN: llc < %s -mtriple=aarch64 -mattr=+neon -global-isel | FileCheck %s
|
||||
|
||||
define i32 @testmsws(float %x) {
|
||||
; CHECK-LABEL: testmsws:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user