Skip to content

Commit 2dea7bd

Browse files
committed
[AArch64][GlobalISel] Legalize NEON smin,smax,umin,umax,fmin,fmax intrinsics
Replace these intrinsics with the corresponding GISel operators during legalization stage to reuse available selection patterns.
1 parent d1f5954 commit 2dea7bd

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,30 @@ bool AArch64LegalizerInfo::legalizeIntrinsic(LegalizerHelper &Helper,
13321332

13331333
return true;
13341334
}
1335+
case Intrinsic::aarch64_neon_smax:
1336+
case Intrinsic::aarch64_neon_smin:
1337+
case Intrinsic::aarch64_neon_umax:
1338+
case Intrinsic::aarch64_neon_umin:
1339+
case Intrinsic::aarch64_neon_fmax:
1340+
case Intrinsic::aarch64_neon_fmin: {
1341+
MachineIRBuilder MIB(MI);
1342+
if (IntrinsicID == Intrinsic::aarch64_neon_smax)
1343+
MIB.buildSMax(MI.getOperand(0), MI.getOperand(2), MI.getOperand(3));
1344+
else if (IntrinsicID == Intrinsic::aarch64_neon_smin)
1345+
MIB.buildSMin(MI.getOperand(0), MI.getOperand(2), MI.getOperand(3));
1346+
else if (IntrinsicID == Intrinsic::aarch64_neon_umax)
1347+
MIB.buildUMax(MI.getOperand(0), MI.getOperand(2), MI.getOperand(3));
1348+
else if (IntrinsicID == Intrinsic::aarch64_neon_umin)
1349+
MIB.buildUMin(MI.getOperand(0), MI.getOperand(2), MI.getOperand(3));
1350+
else if (IntrinsicID == Intrinsic::aarch64_neon_fmax)
1351+
MIB.buildInstr(TargetOpcode::G_FMAXIMUM, {MI.getOperand(0)},
1352+
{MI.getOperand(2), MI.getOperand(3)});
1353+
else if (IntrinsicID == Intrinsic::aarch64_neon_fmin)
1354+
MIB.buildInstr(TargetOpcode::G_FMINIMUM, {MI.getOperand(0)},
1355+
{MI.getOperand(2), MI.getOperand(3)});
1356+
MI.eraseFromParent();
1357+
return true;
1358+
}
13351359
case Intrinsic::experimental_vector_reverse:
13361360
// TODO: Add support for vector_reverse
13371361
return false;

llvm/test/CodeGen/AArch64/arm64-vmax.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple | FileCheck %s
3+
; RUN: llc < %s -global-isel -global-isel-abort=1 -mtriple=arm64-eabi -aarch64-neon-syntax=apple | FileCheck %s
34

45
define <8 x i8> @smax_8b(ptr %A, ptr %B) nounwind {
56
; CHECK-LABEL: smax_8b:

0 commit comments

Comments
 (0)