aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineVerifier.cpp
diff options
context:
space:
mode:
authorThorsten Schütt <schuett@gmail.com>2024-12-04 12:53:15 +0100
committerGitHub <noreply@github.com>2024-12-04 12:53:15 +0100
commit148fdc519cd25b36db9da61a6c6cabe86268dc58 (patch)
tree05e22da7a381f4641dff1cb7bb45b59d678690c1 /llvm/lib/CodeGen/MachineVerifier.cpp
parent041e5c96c4bd247a3dd6099f49143ee66d9205d8 (diff)
downloadllvm-148fdc519cd25b36db9da61a6c6cabe86268dc58.zip
llvm-148fdc519cd25b36db9da61a6c6cabe86268dc58.tar.gz
llvm-148fdc519cd25b36db9da61a6c6cabe86268dc58.tar.bz2
[GlobalISel] Add G_ABDS and G_ABDU instructions (#118122)
The DAG has the same instructions: the signed and unsigned absolute difference of it's input. For AArch64, they map to uabd and sabd for Neon and SVE. The Neon and SVE instructions will require custom patterns. They are pseudo opcodes and are not imported by the IRTranslator. We need combines to create them. PowerPC, ARM, and AArch64 have native instructions. /// i.e trunc(abs(sext(Op0) - sext(Op1))) becomes abds(Op0, Op1) /// or trunc(abs(zext(Op0) - zext(Op1))) becomes abdu(Op0, Op1) For GlobalISel, we are going to write the combines in MIR patterns. see: llvm/test/CodeGen/AArch64/abd-combine.ll - [ ] combine into abd - [ ] legalize and add td patterns
Diffstat (limited to 'llvm/lib/CodeGen/MachineVerifier.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineVerifier.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index b08a93a..8e64e40 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -1585,6 +1585,31 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
break;
}
+ case TargetOpcode::G_ABDS:
+ case TargetOpcode::G_ABDU: {
+ LLT DstTy = MRI->getType(MI->getOperand(0).getReg());
+ LLT SrcTy = MRI->getType(MI->getOperand(1).getReg());
+ LLT SrcTy2 = MRI->getType(MI->getOperand(2).getReg());
+
+ if ((DstTy.isVector() != SrcTy.isVector()) ||
+ (DstTy.isVector() &&
+ DstTy.getElementCount() != SrcTy.getElementCount())) {
+ report("Generic vector abds/abdu must preserve number of lanes", MI);
+ break;
+ }
+
+ if (SrcTy != SrcTy2) {
+ report("Generic abds/abdu must have same input types", MI);
+ break;
+ }
+
+ if (DstTy != SrcTy) {
+ report("Generic abds/abdu must have same input and output types", MI);
+ break;
+ }
+
+ break;
+ }
case TargetOpcode::G_SCMP:
case TargetOpcode::G_UCMP: {
LLT DstTy = MRI->getType(MI->getOperand(0).getReg());