2020-06-03 11:27:55 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2020 Valve Corporation
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#include "aco_ir.h"
|
2020-01-22 19:57:20 +00:00
|
|
|
#include "vulkan/radv_shader.h"
|
2020-07-21 21:48:06 +01:00
|
|
|
#include "c11/threads.h"
|
|
|
|
|
#include "util/debug.h"
|
2020-06-03 11:27:55 +01:00
|
|
|
|
|
|
|
|
namespace aco {
|
|
|
|
|
|
2020-01-22 19:57:20 +00:00
|
|
|
uint64_t debug_flags = 0;
|
|
|
|
|
|
|
|
|
|
static const struct debug_control aco_debug_options[] = {
|
2020-08-18 08:14:06 +02:00
|
|
|
{"validateir", DEBUG_VALIDATE_IR},
|
2020-01-22 19:57:20 +00:00
|
|
|
{"validatera", DEBUG_VALIDATE_RA},
|
|
|
|
|
{"perfwarn", DEBUG_PERFWARN},
|
2020-08-19 10:40:35 +02:00
|
|
|
{"force-waitcnt", DEBUG_FORCE_WAITCNT},
|
2020-08-26 14:24:45 +02:00
|
|
|
{"novn", DEBUG_NO_VN},
|
|
|
|
|
{"noopt", DEBUG_NO_OPT},
|
|
|
|
|
{"nosched", DEBUG_NO_SCHED},
|
2020-01-22 19:57:20 +00:00
|
|
|
{NULL, 0}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static once_flag init_once_flag = ONCE_FLAG_INIT;
|
|
|
|
|
|
|
|
|
|
static void init_once()
|
|
|
|
|
{
|
|
|
|
|
debug_flags = parse_debug_string(getenv("ACO_DEBUG"), aco_debug_options);
|
|
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
/* enable some flags by default on debug builds */
|
2020-08-18 08:14:06 +02:00
|
|
|
debug_flags |= aco::DEBUG_VALIDATE_IR;
|
2020-01-22 19:57:20 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void init()
|
|
|
|
|
{
|
|
|
|
|
call_once(&init_once_flag, init_once);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void init_program(Program *program, Stage stage, struct radv_shader_info *info,
|
|
|
|
|
enum chip_class chip_class, enum radeon_family family,
|
|
|
|
|
ac_shader_config *config)
|
|
|
|
|
{
|
|
|
|
|
program->stage = stage;
|
|
|
|
|
program->config = config;
|
|
|
|
|
program->info = info;
|
|
|
|
|
program->chip_class = chip_class;
|
|
|
|
|
if (family == CHIP_UNKNOWN) {
|
|
|
|
|
switch (chip_class) {
|
|
|
|
|
case GFX6:
|
|
|
|
|
program->family = CHIP_TAHITI;
|
|
|
|
|
break;
|
|
|
|
|
case GFX7:
|
|
|
|
|
program->family = CHIP_BONAIRE;
|
|
|
|
|
break;
|
|
|
|
|
case GFX8:
|
|
|
|
|
program->family = CHIP_POLARIS10;
|
|
|
|
|
break;
|
|
|
|
|
case GFX9:
|
|
|
|
|
program->family = CHIP_VEGA10;
|
|
|
|
|
break;
|
|
|
|
|
case GFX10:
|
|
|
|
|
program->family = CHIP_NAVI10;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
program->family = CHIP_UNKNOWN;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
program->family = family;
|
|
|
|
|
}
|
|
|
|
|
program->wave_size = info->wave_size;
|
|
|
|
|
program->lane_mask = program->wave_size == 32 ? s1 : s2;
|
|
|
|
|
|
|
|
|
|
program->lds_alloc_granule = chip_class >= GFX7 ? 512 : 256;
|
|
|
|
|
program->lds_limit = chip_class >= GFX7 ? 65536 : 32768;
|
|
|
|
|
/* apparently gfx702 also has 16-bank LDS but I can't find a family for that */
|
|
|
|
|
program->has_16bank_lds = family == CHIP_KABINI || family == CHIP_STONEY;
|
|
|
|
|
|
|
|
|
|
program->vgpr_limit = 256;
|
aco: fix num_waves on GFX10+
There are half the SIMDs per CU and physical_vgprs should be 512 instead
of 256.
fossil-db (GFX10.3):
Totals from 3622 (2.60% of 139391) affected shaders:
VGPRs: 298192 -> 289732 (-2.84%); split: -3.43%, +0.59%
CodeSize: 29443432 -> 29458388 (+0.05%); split: -0.00%, +0.06%
MaxWaves: 21703 -> 23395 (+7.80%); split: +7.84%, -0.05%
Instrs: 5677920 -> 5681438 (+0.06%); split: -0.01%, +0.07%
Cycles: 280715524 -> 280895676 (+0.06%); split: -0.00%, +0.07%
VMEM: 981142 -> 981894 (+0.08%); split: +0.18%, -0.10%
SMEM: 243315 -> 243454 (+0.06%); split: +0.07%, -0.02%
VClause: 88991 -> 89767 (+0.87%); split: -0.02%, +0.89%
SClause: 200660 -> 200659 (-0.00%); split: -0.00%, +0.00%
Copies: 430729 -> 434160 (+0.80%); split: -0.07%, +0.86%
Branches: 158004 -> 158021 (+0.01%); split: -0.01%, +0.02%
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8523>
2021-01-19 11:37:52 +00:00
|
|
|
program->physical_vgprs = 256;
|
2021-02-02 17:33:09 +01:00
|
|
|
program->vgpr_alloc_granule = 4;
|
2020-01-22 19:57:20 +00:00
|
|
|
|
|
|
|
|
if (chip_class >= GFX10) {
|
aco: fix waves calculation for wave32
fossil-db (GFX10.3, wave32):
Totals from 176 (0.13% of 139391) affected shaders:
SGPRs: 16648 -> 16640 (-0.05%)
VGPRs: 18920 -> 19076 (+0.82%); split: -0.30%, +1.12%
CodeSize: 2354172 -> 2354288 (+0.00%); split: -0.01%, +0.01%
MaxWaves: 1618 -> 1627 (+0.56%); split: +0.68%, -0.12%
Instrs: 435756 -> 435761 (+0.00%); split: -0.02%, +0.02%
Cycles: 8858360 -> 8869960 (+0.13%); split: -0.01%, +0.14%
VMEM: 55899 -> 57220 (+2.36%); split: +2.53%, -0.17%
SMEM: 10323 -> 10374 (+0.49%); split: +0.73%, -0.23%
VClause: 8307 -> 8290 (-0.20%); split: -0.24%, +0.04%
SClause: 16573 -> 16577 (+0.02%); split: -0.01%, +0.03%
Copies: 24641 -> 24652 (+0.04%); split: -0.24%, +0.28%
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8761>
2021-01-28 11:04:02 +00:00
|
|
|
program->physical_sgprs = 5120; /* doesn't matter as long as it's at least 128 * 40 */
|
|
|
|
|
program->physical_vgprs = program->wave_size == 32 ? 1024 : 512;
|
2021-02-02 17:33:09 +01:00
|
|
|
program->sgpr_alloc_granule = 128;
|
aco: use VCC as regular SGPR pair on GFX10
There is no need to reserve it for special purposes, only.
Totals from 139391 (100.00% of 139391) affected shaders (Navi10):
VGPRs: 4738296 -> 4738156 (-0.00%); split: -0.01%, +0.00%
SpillSGPRs: 16188 -> 14968 (-7.54%); split: -7.60%, +0.06%
CodeSize: 294204472 -> 294118048 (-0.03%); split: -0.04%, +0.01%
MaxWaves: 2119584 -> 2119619 (+0.00%); split: +0.00%, -0.00%
Instrs: 56075079 -> 56056235 (-0.03%); split: -0.05%, +0.01%
Cycles: 1757781564 -> 1755354032 (-0.14%); split: -0.16%, +0.02%
VMEM: 52995887 -> 52996319 (+0.00%); split: +0.07%, -0.07%
SMEM: 9005338 -> 9004858 (-0.01%); split: +0.16%, -0.17%
VClause: 1178436 -> 1178331 (-0.01%); split: -0.02%, +0.01%
SClause: 2403649 -> 2404542 (+0.04%); split: -0.14%, +0.18%
Copies: 3447073 -> 3432417 (-0.43%); split: -0.66%, +0.23%
Branches: 1166542 -> 1166422 (-0.01%); split: -0.11%, +0.10%
PreSGPRs: 4229322 -> 4235538 (+0.15%)
PreVGPRs: 3817111 -> 3817040 (-0.00%)
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8921>
2021-02-02 17:46:35 +01:00
|
|
|
program->sgpr_limit = 108; /* includes VCC, which can be treated as s[106-107] on GFX10+ */
|
2020-06-18 14:31:13 +01:00
|
|
|
if (chip_class >= GFX10_3)
|
2021-02-02 17:33:09 +01:00
|
|
|
program->vgpr_alloc_granule = program->wave_size == 32 ? 16 : 8;
|
2020-06-18 14:31:13 +01:00
|
|
|
else
|
2021-02-02 17:33:09 +01:00
|
|
|
program->vgpr_alloc_granule = program->wave_size == 32 ? 8 : 4;
|
2020-01-22 19:57:20 +00:00
|
|
|
} else if (program->chip_class >= GFX8) {
|
|
|
|
|
program->physical_sgprs = 800;
|
2021-02-02 17:33:09 +01:00
|
|
|
program->sgpr_alloc_granule = 16;
|
|
|
|
|
program->sgpr_limit = 102;
|
2021-02-05 14:36:39 +01:00
|
|
|
if (family == CHIP_TONGA || family == CHIP_ICELAND)
|
|
|
|
|
program->sgpr_alloc_granule = 96; /* workaround hardware bug */
|
2020-01-22 19:57:20 +00:00
|
|
|
} else {
|
|
|
|
|
program->physical_sgprs = 512;
|
2021-02-02 17:33:09 +01:00
|
|
|
program->sgpr_alloc_granule = 8;
|
2020-01-22 19:57:20 +00:00
|
|
|
program->sgpr_limit = 104;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-28 11:07:26 +00:00
|
|
|
program->wgp_mode = chip_class >= GFX10; /* assume WGP is used on Navi */
|
|
|
|
|
|
2020-01-22 19:57:20 +00:00
|
|
|
program->next_fp_mode.preserve_signed_zero_inf_nan32 = false;
|
|
|
|
|
program->next_fp_mode.preserve_signed_zero_inf_nan16_64 = false;
|
|
|
|
|
program->next_fp_mode.must_flush_denorms32 = false;
|
|
|
|
|
program->next_fp_mode.must_flush_denorms16_64 = false;
|
|
|
|
|
program->next_fp_mode.care_about_round32 = false;
|
|
|
|
|
program->next_fp_mode.care_about_round16_64 = false;
|
|
|
|
|
program->next_fp_mode.denorm16_64 = fp_denorm_keep;
|
|
|
|
|
program->next_fp_mode.denorm32 = 0;
|
|
|
|
|
program->next_fp_mode.round16_64 = fp_round_ne;
|
|
|
|
|
program->next_fp_mode.round32 = fp_round_ne;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-26 15:54:22 +01:00
|
|
|
memory_sync_info get_sync_info(const Instruction* instr)
|
|
|
|
|
{
|
|
|
|
|
switch (instr->format) {
|
|
|
|
|
case Format::SMEM:
|
2021-01-21 16:13:34 +00:00
|
|
|
return instr->smem().sync;
|
2020-06-26 15:54:22 +01:00
|
|
|
case Format::MUBUF:
|
2021-01-21 16:13:34 +00:00
|
|
|
return instr->mubuf().sync;
|
2020-06-26 15:54:22 +01:00
|
|
|
case Format::MIMG:
|
2021-01-21 16:13:34 +00:00
|
|
|
return instr->mimg().sync;
|
2020-06-26 15:54:22 +01:00
|
|
|
case Format::MTBUF:
|
2021-01-21 16:13:34 +00:00
|
|
|
return instr->mtbuf().sync;
|
2020-06-26 15:54:22 +01:00
|
|
|
case Format::FLAT:
|
|
|
|
|
case Format::GLOBAL:
|
|
|
|
|
case Format::SCRATCH:
|
2021-01-21 16:13:34 +00:00
|
|
|
return instr->flatlike().sync;
|
2020-06-26 15:54:22 +01:00
|
|
|
case Format::DS:
|
2021-01-21 16:13:34 +00:00
|
|
|
return instr->ds().sync;
|
2020-06-26 15:54:22 +01:00
|
|
|
default:
|
|
|
|
|
return memory_sync_info();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-11 17:49:40 +01:00
|
|
|
bool can_use_SDWA(chip_class chip, const aco_ptr<Instruction>& instr)
|
|
|
|
|
{
|
|
|
|
|
if (!instr->isVALU())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (chip < GFX8 || instr->isDPP())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (instr->isSDWA())
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (instr->isVOP3()) {
|
2021-01-21 16:13:34 +00:00
|
|
|
VOP3_instruction& vop3 = instr->vop3();
|
2020-05-11 17:49:40 +01:00
|
|
|
if (instr->format == Format::VOP3)
|
|
|
|
|
return false;
|
2021-01-21 16:13:34 +00:00
|
|
|
if (vop3.clamp && instr->format == asVOP3(Format::VOPC) && chip != GFX8)
|
2020-05-11 17:49:40 +01:00
|
|
|
return false;
|
2021-01-21 16:13:34 +00:00
|
|
|
if (vop3.omod && chip < GFX9)
|
2020-05-11 17:49:40 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
//TODO: return true if we know we will use vcc
|
|
|
|
|
if (instr->definitions.size() >= 2)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
for (unsigned i = 1; i < instr->operands.size(); i++) {
|
|
|
|
|
if (instr->operands[i].isLiteral())
|
|
|
|
|
return false;
|
|
|
|
|
if (chip < GFX9 && !instr->operands[i].isOfType(RegType::vgpr))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!instr->operands.empty()) {
|
|
|
|
|
if (instr->operands[0].isLiteral())
|
|
|
|
|
return false;
|
|
|
|
|
if (chip < GFX9 && !instr->operands[0].isOfType(RegType::vgpr))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool is_mac = instr->opcode == aco_opcode::v_mac_f32 ||
|
|
|
|
|
instr->opcode == aco_opcode::v_mac_f16 ||
|
|
|
|
|
instr->opcode == aco_opcode::v_fmac_f32 ||
|
|
|
|
|
instr->opcode == aco_opcode::v_fmac_f16;
|
|
|
|
|
|
|
|
|
|
if (chip != GFX8 && is_mac)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
//TODO: return true if we know we will use vcc
|
2021-01-20 15:27:16 +00:00
|
|
|
if (instr->isVOPC())
|
2020-05-11 17:49:40 +01:00
|
|
|
return false;
|
|
|
|
|
if (instr->operands.size() >= 3 && !is_mac)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return instr->opcode != aco_opcode::v_madmk_f32 &&
|
|
|
|
|
instr->opcode != aco_opcode::v_madak_f32 &&
|
|
|
|
|
instr->opcode != aco_opcode::v_madmk_f16 &&
|
|
|
|
|
instr->opcode != aco_opcode::v_madak_f16 &&
|
|
|
|
|
instr->opcode != aco_opcode::v_readfirstlane_b32 &&
|
|
|
|
|
instr->opcode != aco_opcode::v_clrexcp &&
|
|
|
|
|
instr->opcode != aco_opcode::v_swap_b32;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* updates "instr" and returns the old instruction (or NULL if no update was needed) */
|
|
|
|
|
aco_ptr<Instruction> convert_to_SDWA(chip_class chip, aco_ptr<Instruction>& instr)
|
|
|
|
|
{
|
|
|
|
|
if (instr->isSDWA())
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
aco_ptr<Instruction> tmp = std::move(instr);
|
|
|
|
|
Format format = (Format)(((uint16_t)tmp->format & ~(uint16_t)Format::VOP3) | (uint16_t)Format::SDWA);
|
|
|
|
|
instr.reset(create_instruction<SDWA_instruction>(tmp->opcode, format, tmp->operands.size(), tmp->definitions.size()));
|
|
|
|
|
std::copy(tmp->operands.cbegin(), tmp->operands.cend(), instr->operands.begin());
|
|
|
|
|
std::copy(tmp->definitions.cbegin(), tmp->definitions.cend(), instr->definitions.begin());
|
|
|
|
|
|
2021-01-21 16:13:34 +00:00
|
|
|
SDWA_instruction& sdwa = instr->sdwa();
|
2020-05-11 17:49:40 +01:00
|
|
|
|
|
|
|
|
if (tmp->isVOP3()) {
|
2021-01-21 16:13:34 +00:00
|
|
|
VOP3_instruction& vop3 = tmp->vop3();
|
|
|
|
|
memcpy(sdwa.neg, vop3.neg, sizeof(sdwa.neg));
|
|
|
|
|
memcpy(sdwa.abs, vop3.abs, sizeof(sdwa.abs));
|
|
|
|
|
sdwa.omod = vop3.omod;
|
|
|
|
|
sdwa.clamp = vop3.clamp;
|
2020-05-11 17:49:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < instr->operands.size(); i++) {
|
2020-08-22 20:45:54 +02:00
|
|
|
/* SDWA only uses operands 0 and 1. */
|
|
|
|
|
if (i >= 2)
|
|
|
|
|
break;
|
|
|
|
|
|
2020-05-11 17:49:40 +01:00
|
|
|
switch (instr->operands[i].bytes()) {
|
|
|
|
|
case 1:
|
2021-01-21 16:13:34 +00:00
|
|
|
sdwa.sel[i] = sdwa_ubyte;
|
2020-05-11 17:49:40 +01:00
|
|
|
break;
|
|
|
|
|
case 2:
|
2021-01-21 16:13:34 +00:00
|
|
|
sdwa.sel[i] = sdwa_uword;
|
2020-05-11 17:49:40 +01:00
|
|
|
break;
|
|
|
|
|
case 4:
|
2021-01-21 16:13:34 +00:00
|
|
|
sdwa.sel[i] = sdwa_udword;
|
2020-05-11 17:49:40 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
switch (instr->definitions[0].bytes()) {
|
|
|
|
|
case 1:
|
2021-01-21 16:13:34 +00:00
|
|
|
sdwa.dst_sel = sdwa_ubyte;
|
|
|
|
|
sdwa.dst_preserve = true;
|
2020-05-11 17:49:40 +01:00
|
|
|
break;
|
|
|
|
|
case 2:
|
2021-01-21 16:13:34 +00:00
|
|
|
sdwa.dst_sel = sdwa_uword;
|
|
|
|
|
sdwa.dst_preserve = true;
|
2020-05-11 17:49:40 +01:00
|
|
|
break;
|
|
|
|
|
case 4:
|
2021-01-21 16:13:34 +00:00
|
|
|
sdwa.dst_sel = sdwa_udword;
|
2020-05-11 17:49:40 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (instr->definitions[0].getTemp().type() == RegType::sgpr && chip == GFX8)
|
|
|
|
|
instr->definitions[0].setFixed(vcc);
|
|
|
|
|
if (instr->definitions.size() >= 2)
|
|
|
|
|
instr->definitions[1].setFixed(vcc);
|
|
|
|
|
if (instr->operands.size() >= 3)
|
|
|
|
|
instr->operands[2].setFixed(vcc);
|
|
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-03 11:27:55 +01:00
|
|
|
bool can_use_opsel(chip_class chip, aco_opcode op, int idx, bool high)
|
|
|
|
|
{
|
|
|
|
|
/* opsel is only GFX9+ */
|
|
|
|
|
if ((high || idx == -1) && chip < GFX9)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
|
case aco_opcode::v_div_fixup_f16:
|
|
|
|
|
case aco_opcode::v_fma_f16:
|
|
|
|
|
case aco_opcode::v_mad_f16:
|
|
|
|
|
case aco_opcode::v_mad_u16:
|
|
|
|
|
case aco_opcode::v_mad_i16:
|
|
|
|
|
case aco_opcode::v_med3_f16:
|
|
|
|
|
case aco_opcode::v_med3_i16:
|
|
|
|
|
case aco_opcode::v_med3_u16:
|
|
|
|
|
case aco_opcode::v_min3_f16:
|
|
|
|
|
case aco_opcode::v_min3_i16:
|
|
|
|
|
case aco_opcode::v_min3_u16:
|
|
|
|
|
case aco_opcode::v_max3_f16:
|
|
|
|
|
case aco_opcode::v_max3_i16:
|
|
|
|
|
case aco_opcode::v_max3_u16:
|
|
|
|
|
case aco_opcode::v_max_u16_e64:
|
|
|
|
|
case aco_opcode::v_max_i16_e64:
|
|
|
|
|
case aco_opcode::v_min_u16_e64:
|
|
|
|
|
case aco_opcode::v_min_i16_e64:
|
|
|
|
|
case aco_opcode::v_add_i16:
|
|
|
|
|
case aco_opcode::v_sub_i16:
|
|
|
|
|
case aco_opcode::v_add_u16_e64:
|
|
|
|
|
case aco_opcode::v_sub_u16_e64:
|
|
|
|
|
case aco_opcode::v_lshlrev_b16_e64:
|
|
|
|
|
case aco_opcode::v_lshrrev_b16_e64:
|
|
|
|
|
case aco_opcode::v_ashrrev_i16_e64:
|
|
|
|
|
case aco_opcode::v_mul_lo_u16_e64:
|
|
|
|
|
return true;
|
|
|
|
|
case aco_opcode::v_pack_b32_f16:
|
2020-08-17 11:36:24 +01:00
|
|
|
case aco_opcode::v_cvt_pknorm_i16_f16:
|
|
|
|
|
case aco_opcode::v_cvt_pknorm_u16_f16:
|
2020-06-03 11:27:55 +01:00
|
|
|
return idx != -1;
|
|
|
|
|
case aco_opcode::v_mad_u32_u16:
|
|
|
|
|
case aco_opcode::v_mad_i32_i16:
|
|
|
|
|
return idx >= 0 && idx < 2;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-01 16:30:06 +01:00
|
|
|
uint32_t get_reduction_identity(ReduceOp op, unsigned idx)
|
|
|
|
|
{
|
|
|
|
|
switch (op) {
|
|
|
|
|
case iadd8:
|
|
|
|
|
case iadd16:
|
|
|
|
|
case iadd32:
|
|
|
|
|
case iadd64:
|
|
|
|
|
case fadd16:
|
|
|
|
|
case fadd32:
|
|
|
|
|
case fadd64:
|
|
|
|
|
case ior8:
|
|
|
|
|
case ior16:
|
|
|
|
|
case ior32:
|
|
|
|
|
case ior64:
|
|
|
|
|
case ixor8:
|
|
|
|
|
case ixor16:
|
|
|
|
|
case ixor32:
|
|
|
|
|
case ixor64:
|
|
|
|
|
case umax8:
|
|
|
|
|
case umax16:
|
|
|
|
|
case umax32:
|
|
|
|
|
case umax64:
|
|
|
|
|
return 0;
|
|
|
|
|
case imul8:
|
|
|
|
|
case imul16:
|
|
|
|
|
case imul32:
|
|
|
|
|
case imul64:
|
|
|
|
|
return idx ? 0 : 1;
|
|
|
|
|
case fmul16:
|
|
|
|
|
return 0x3c00u; /* 1.0 */
|
|
|
|
|
case fmul32:
|
|
|
|
|
return 0x3f800000u; /* 1.0 */
|
|
|
|
|
case fmul64:
|
|
|
|
|
return idx ? 0x3ff00000u : 0u; /* 1.0 */
|
|
|
|
|
case imin8:
|
|
|
|
|
return INT8_MAX;
|
|
|
|
|
case imin16:
|
|
|
|
|
return INT16_MAX;
|
|
|
|
|
case imin32:
|
|
|
|
|
return INT32_MAX;
|
|
|
|
|
case imin64:
|
|
|
|
|
return idx ? 0x7fffffffu : 0xffffffffu;
|
|
|
|
|
case imax8:
|
|
|
|
|
return INT8_MIN;
|
|
|
|
|
case imax16:
|
|
|
|
|
return INT16_MIN;
|
|
|
|
|
case imax32:
|
|
|
|
|
return INT32_MIN;
|
|
|
|
|
case imax64:
|
|
|
|
|
return idx ? 0x80000000u : 0;
|
|
|
|
|
case umin8:
|
|
|
|
|
case umin16:
|
|
|
|
|
case iand8:
|
|
|
|
|
case iand16:
|
|
|
|
|
return 0xffffffffu;
|
|
|
|
|
case umin32:
|
|
|
|
|
case umin64:
|
|
|
|
|
case iand32:
|
|
|
|
|
case iand64:
|
|
|
|
|
return 0xffffffffu;
|
|
|
|
|
case fmin16:
|
|
|
|
|
return 0x7c00u; /* infinity */
|
|
|
|
|
case fmin32:
|
|
|
|
|
return 0x7f800000u; /* infinity */
|
|
|
|
|
case fmin64:
|
|
|
|
|
return idx ? 0x7ff00000u : 0u; /* infinity */
|
|
|
|
|
case fmax16:
|
|
|
|
|
return 0xfc00u; /* negative infinity */
|
|
|
|
|
case fmax32:
|
|
|
|
|
return 0xff800000u; /* negative infinity */
|
|
|
|
|
case fmax64:
|
|
|
|
|
return idx ? 0xfff00000u : 0u; /* negative infinity */
|
|
|
|
|
default:
|
|
|
|
|
unreachable("Invalid reduction operation");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-12 16:58:35 +02:00
|
|
|
bool needs_exec_mask(const Instruction* instr) {
|
|
|
|
|
if (instr->isSALU())
|
|
|
|
|
return instr->reads_exec();
|
2021-01-20 15:27:16 +00:00
|
|
|
if (instr->isSMEM() || instr->isSALU())
|
2020-08-12 16:58:35 +02:00
|
|
|
return false;
|
2021-01-20 15:27:16 +00:00
|
|
|
if (instr->isBarrier())
|
2020-08-12 16:58:35 +02:00
|
|
|
return false;
|
|
|
|
|
|
2021-01-20 15:27:16 +00:00
|
|
|
if (instr->isPseudo()) {
|
2020-08-12 16:58:35 +02:00
|
|
|
switch (instr->opcode) {
|
|
|
|
|
case aco_opcode::p_create_vector:
|
|
|
|
|
case aco_opcode::p_extract_vector:
|
|
|
|
|
case aco_opcode::p_split_vector:
|
|
|
|
|
for (Definition def : instr->definitions) {
|
|
|
|
|
if (def.getTemp().type() == RegType::vgpr)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
case aco_opcode::p_spill:
|
|
|
|
|
case aco_opcode::p_reload:
|
|
|
|
|
return false;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (instr->opcode == aco_opcode::v_readlane_b32 ||
|
|
|
|
|
instr->opcode == aco_opcode::v_readlane_b32_e64 ||
|
|
|
|
|
instr->opcode == aco_opcode::v_writelane_b32 ||
|
|
|
|
|
instr->opcode == aco_opcode::v_writelane_b32_e64)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-03 11:27:55 +01:00
|
|
|
}
|