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 23def uchar_to_float : GICombineRule< 24 (defs root:$itofp), 25 (match (wip_match_opcode G_UITOFP, G_SITOFP):$itofp, 26 [{ return matchUCharToFloat(*${itofp}, MRI, *MF, Helper); }]), 27 (apply [{ applyUCharToFloat(*${itofp}); }])>; 28 29 30// Combines which should only apply on SI/VI 31def gfx6gfx7_combines : GICombineGroup<[fcmp_select_to_fmin_fmax_legacy]>; 32 33 34def AMDGPUPreLegalizerCombinerHelper: GICombinerHelper< 35 "AMDGPUGenPreLegalizerCombinerHelper", [all_combines, 36 elide_br_by_inverting_cond]> { 37 let DisableRuleOption = "amdgpuprelegalizercombiner-disable-rule"; 38} 39 40def AMDGPUPostLegalizerCombinerHelper: GICombinerHelper< 41 "AMDGPUGenPostLegalizerCombinerHelper", [all_combines, 42 gfx6gfx7_combines, uchar_to_float]> { 43 let DisableRuleOption = "amdgpupostlegalizercombiner-disable-rule"; 44} 45