Files
clang-p2996/llvm/test/CodeGen/SPIRV/instructions/vector-floating-point-arithmetic.ll
Vyacheslav Levytskyy 67d3ef74b3 [SPIR-V] Rework usage of virtual registers' types and classes (#104104)
This PR continues https://github.com/llvm/llvm-project/pull/101732
changes in virtual register processing aimed to improve correctness of
emitted MIR between passes from the perspective of MachineVerifier.
Namely, the following changes are introduced:
* register classes (lib/Target/SPIRV/SPIRVRegisterInfo.td) and
instruction patterns (lib/Target/SPIRV/SPIRVInstrInfo.td) are corrected
and simplified (by removing unnecessary sophisticated options) -- e.g.,
this PR gets rid of duplicating 32/64 bits patterns, removes ANYID
register class and simplifies definition of the rest of register
classes,
* hardcoded LLT scalar types in passes before instruction selection are
corrected -- the goal is to have correct bit width before instruction
selection, and use 64 bits registers for pattern matching in the
instruction selection pass; 32-bit registers remain where they are
described in such terms by SPIR-V specification (like, for example,
creation of virtual registers for scope/mem semantics operands),
* rework virtual register type/class assignment for calls/builtins
lowering,
* a series of minor changes to fix validity of emitted code between
passes:
  - ensure that that bitcast changes the type,
  - fix the pattern for instruction selection for OpExtInst,
  - simplify inline asm operands usage,
  - account for arbitrary integer sizes / update legalizer rules;
* add '-verify-machineinstrs' to existed test cases.

See also https://github.com/llvm/llvm-project/issues/88129 that this PR
may resolve.

This PR fixes a great number of issues reported by MachineVerifier and,
as a result, reduces a number of failed test cases for the mode with
expensive checks set on from ~200 to ~57.
2024-08-22 09:40:27 +02:00

108 lines
3.4 KiB
LLVM

; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
; CHECK-DAG: OpName [[VECTOR_FNEG:%.+]] "vector_fneg"
; CHECK-DAG: OpName [[VECTOR_FADD:%.+]] "vector_fadd"
; CHECK-DAG: OpName [[VECTOR_FSUB:%.+]] "vector_fsub"
; CHECK-DAG: OpName [[VECTOR_FMUL:%.+]] "vector_fmul"
; CHECK-DAG: OpName [[VECTOR_FDIV:%.+]] "vector_fdiv"
; CHECK-DAG: OpName [[VECTOR_FREM:%.+]] "vector_frem"
;; TODO: add test for OpFMod
; CHECK-NOT: DAG-FENCE
; CHECK-DAG: [[FP16:%.+]] = OpTypeFloat 16
; CHECK-DAG: [[VECTOR:%.+]] = OpTypeVector [[FP16]]
; CHECK-DAG: [[VECTOR_FN:%.+]] = OpTypeFunction [[VECTOR]] [[VECTOR]] [[VECTOR]]
; CHECK-NOT: DAG-FENCE
;; Test fneg on vector:
define <2 x half> @vector_fneg(<2 x half> %a, <2 x half> %unused) {
%c = fneg <2 x half> %a
ret <2 x half> %c
}
; CHECK: [[VECTOR_FNEG]] = OpFunction [[VECTOR]] None [[VECTOR_FN]]
; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[VECTOR]]
; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[VECTOR]]
; CHECK: OpLabel
; CHECK: [[C:%.+]] = OpFNegate [[VECTOR]] [[A]]
; CHECK: OpReturnValue [[C]]
; CHECK-NEXT: OpFunctionEnd
;; Test fadd on vector:
define <2 x half> @vector_fadd(<2 x half> %a, <2 x half> %b) {
%c = fadd <2 x half> %a, %b
ret <2 x half> %c
}
; CHECK: [[VECTOR_FADD]] = OpFunction [[VECTOR]] None [[VECTOR_FN]]
; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[VECTOR]]
; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[VECTOR]]
; CHECK: OpLabel
; CHECK: [[C:%.+]] = OpFAdd [[VECTOR]] [[A]] [[B]]
; CHECK: OpReturnValue [[C]]
; CHECK-NEXT: OpFunctionEnd
;; Test fsub on vector:
define <2 x half> @vector_fsub(<2 x half> %a, <2 x half> %b) {
%c = fsub <2 x half> %a, %b
ret <2 x half> %c
}
; CHECK: [[VECTOR_FSUB]] = OpFunction [[VECTOR]] None [[VECTOR_FN]]
; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[VECTOR]]
; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[VECTOR]]
; CHECK: OpLabel
; CHECK: [[C:%.+]] = OpFSub [[VECTOR]] [[A]] [[B]]
; CHECK: OpReturnValue [[C]]
; CHECK-NEXT: OpFunctionEnd
;; Test fmul on vector:
define <2 x half> @vector_fmul(<2 x half> %a, <2 x half> %b) {
%c = fmul <2 x half> %a, %b
ret <2 x half> %c
}
; CHECK: [[VECTOR_FMUL]] = OpFunction [[VECTOR]] None [[VECTOR_FN]]
; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[VECTOR]]
; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[VECTOR]]
; CHECK: OpLabel
; CHECK: [[C:%.+]] = OpFMul [[VECTOR]] [[A]] [[B]]
; CHECK: OpReturnValue [[C]]
; CHECK-NEXT: OpFunctionEnd
;; Test fdiv on vector:
define <2 x half> @vector_fdiv(<2 x half> %a, <2 x half> %b) {
%c = fdiv <2 x half> %a, %b
ret <2 x half> %c
}
; CHECK: [[VECTOR_FDIV]] = OpFunction [[VECTOR]] None [[VECTOR_FN]]
; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[VECTOR]]
; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[VECTOR]]
; CHECK: OpLabel
; CHECK: [[C:%.+]] = OpFDiv [[VECTOR]] [[A]] [[B]]
; CHECK: OpReturnValue [[C]]
; CHECK-NEXT: OpFunctionEnd
;; Test frem on vector:
define <2 x half> @vector_frem(<2 x half> %a, <2 x half> %b) {
%c = frem <2 x half> %a, %b
ret <2 x half> %c
}
; CHECK: [[VECTOR_FREM]] = OpFunction [[VECTOR]] None [[VECTOR_FN]]
; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[VECTOR]]
; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[VECTOR]]
; CHECK: OpLabel
; CHECK: [[C:%.+]] = OpFRem [[VECTOR]] [[A]] [[B]]
; CHECK: OpReturnValue [[C]]
; CHECK-NEXT: OpFunctionEnd