1//=- AMDGPUCombine.td - Define AMDGPU Combine Rules ----------*- tablegen -*-=// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8 9include "llvm/Target/GlobalISel/Combine.td" 10 11// TODO: This really belongs after legalization after scalarization. 12// TODO: GICombineRules should accept subtarget predicates 13 14def fmin_fmax_legacy_matchdata : GIDefMatchData<"FMinFMaxLegacyInfo">; 15 16def fcmp_select_to_fmin_fmax_legacy : GICombineRule< 17 (defs root:$select, fmin_fmax_legacy_matchdata:$matchinfo), 18 (match (wip_match_opcode G_SELECT):$select, 19 [{ return matchFMinFMaxLegacy(*${select}, MRI, *MF, ${matchinfo}); }]), 20 (apply [{ applySelectFCmpToFMinToFMaxLegacy(*${select}, ${matchinfo}); }])>; 21 22 23// Combines which should only apply on SI/VI 24def gfx6gfx7_combines : GICombineGroup<[fcmp_select_to_fmin_fmax_legacy]>; 25 26 27def AMDGPUPreLegalizerCombinerHelper: GICombinerHelper< 28 "AMDGPUGenPreLegalizerCombinerHelper", [all_combines, 29 elide_br_by_inverting_cond, 30 gfx6gfx7_combines]> { 31 let DisableRuleOption = "amdgpuprelegalizercombiner-disable-rule"; 32} 33