LLVM  14.0.0git
AMDGPUPostLegalizerCombiner.cpp
Go to the documentation of this file.
1 //=== lib/CodeGen/GlobalISel/AMDGPUPostLegalizerCombiner.cpp ---------------===//
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 //
9 // This pass does combining of machine instructions at the generic MI level,
10 // after the legalizer.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "AMDGPU.h"
15 #include "AMDGPULegalizerInfo.h"
16 #include "GCNSubtarget.h"
26 
27 #define DEBUG_TYPE "amdgpu-postlegalizer-combiner"
28 
29 using namespace llvm;
30 using namespace MIPatternMatch;
31 
33 protected:
38 
39 public:
41  : B(B), MF(B.getMF()), MRI(*B.getMRI()), Helper(Helper){};
42 
49  };
50 
51  // TODO: Make sure fmin_legacy/fmax_legacy don't canonicalize
52  bool matchFMinFMaxLegacy(MachineInstr &MI, FMinFMaxLegacyInfo &Info);
53  void applySelectFCmpToFMinToFMaxLegacy(MachineInstr &MI,
54  const FMinFMaxLegacyInfo &Info);
55 
56  bool matchUCharToFloat(MachineInstr &MI);
57  void applyUCharToFloat(MachineInstr &MI);
58 
59  // FIXME: Should be able to have 2 separate matchdatas rather than custom
60  // struct boilerplate.
63  unsigned ShiftOffset;
64  };
65 
66  bool matchCvtF32UByteN(MachineInstr &MI, CvtF32UByteMatchInfo &MatchInfo);
67  void applyCvtF32UByteN(MachineInstr &MI,
68  const CvtF32UByteMatchInfo &MatchInfo);
69 
70  bool matchRemoveFcanonicalize(MachineInstr &MI, Register &Reg);
71 };
72 
75  // FIXME: Combines should have subtarget predicates, and we shouldn't need
76  // this here.
77  if (!MF.getSubtarget<GCNSubtarget>().hasFminFmaxLegacy())
78  return false;
79 
80  // FIXME: Type predicate on pattern
81  if (MRI.getType(MI.getOperand(0).getReg()) != LLT::scalar(32))
82  return false;
83 
84  Register Cond = MI.getOperand(1).getReg();
85  if (!MRI.hasOneNonDBGUse(Cond) ||
86  !mi_match(Cond, MRI,
87  m_GFCmp(m_Pred(Info.Pred), m_Reg(Info.LHS), m_Reg(Info.RHS))))
88  return false;
89 
90  Info.True = MI.getOperand(2).getReg();
91  Info.False = MI.getOperand(3).getReg();
92 
93  if (!(Info.LHS == Info.True && Info.RHS == Info.False) &&
94  !(Info.LHS == Info.False && Info.RHS == Info.True))
95  return false;
96 
97  switch (Info.Pred) {
99  case CmpInst::FCMP_OEQ:
100  case CmpInst::FCMP_ONE:
101  case CmpInst::FCMP_ORD:
102  case CmpInst::FCMP_UNO:
103  case CmpInst::FCMP_UEQ:
104  case CmpInst::FCMP_UNE:
105  case CmpInst::FCMP_TRUE:
106  return false;
107  default:
108  return true;
109  }
110 }
111 
114  B.setInstrAndDebugLoc(MI);
115  auto buildNewInst = [&MI, this](unsigned Opc, Register X, Register Y) {
116  B.buildInstr(Opc, {MI.getOperand(0)}, {X, Y}, MI.getFlags());
117  };
118 
119  switch (Info.Pred) {
120  case CmpInst::FCMP_ULT:
121  case CmpInst::FCMP_ULE:
122  if (Info.LHS == Info.True)
123  buildNewInst(AMDGPU::G_AMDGPU_FMIN_LEGACY, Info.RHS, Info.LHS);
124  else
125  buildNewInst(AMDGPU::G_AMDGPU_FMAX_LEGACY, Info.LHS, Info.RHS);
126  break;
127  case CmpInst::FCMP_OLE:
128  case CmpInst::FCMP_OLT: {
129  // We need to permute the operands to get the correct NaN behavior. The
130  // selected operand is the second one based on the failing compare with NaN,
131  // so permute it based on the compare type the hardware uses.
132  if (Info.LHS == Info.True)
133  buildNewInst(AMDGPU::G_AMDGPU_FMIN_LEGACY, Info.LHS, Info.RHS);
134  else
135  buildNewInst(AMDGPU::G_AMDGPU_FMAX_LEGACY, Info.RHS, Info.LHS);
136  break;
137  }
138  case CmpInst::FCMP_UGE:
139  case CmpInst::FCMP_UGT: {
140  if (Info.LHS == Info.True)
141  buildNewInst(AMDGPU::G_AMDGPU_FMAX_LEGACY, Info.RHS, Info.LHS);
142  else
143  buildNewInst(AMDGPU::G_AMDGPU_FMIN_LEGACY, Info.LHS, Info.RHS);
144  break;
145  }
146  case CmpInst::FCMP_OGT:
147  case CmpInst::FCMP_OGE: {
148  if (Info.LHS == Info.True)
149  buildNewInst(AMDGPU::G_AMDGPU_FMAX_LEGACY, Info.LHS, Info.RHS);
150  else
151  buildNewInst(AMDGPU::G_AMDGPU_FMIN_LEGACY, Info.RHS, Info.LHS);
152  break;
153  }
154  default:
155  llvm_unreachable("predicate should not have matched");
156  }
157 
158  MI.eraseFromParent();
159 }
160 
162  Register DstReg = MI.getOperand(0).getReg();
163 
164  // TODO: We could try to match extracting the higher bytes, which would be
165  // easier if i8 vectors weren't promoted to i32 vectors, particularly after
166  // types are legalized. v4i8 -> v4f32 is probably the only case to worry
167  // about in practice.
168  LLT Ty = MRI.getType(DstReg);
169  if (Ty == LLT::scalar(32) || Ty == LLT::scalar(16)) {
170  Register SrcReg = MI.getOperand(1).getReg();
171  unsigned SrcSize = MRI.getType(SrcReg).getSizeInBits();
172  assert(SrcSize == 16 || SrcSize == 32 || SrcSize == 64);
173  const APInt Mask = APInt::getHighBitsSet(SrcSize, SrcSize - 8);
174  return Helper.getKnownBits()->maskedValueIsZero(SrcReg, Mask);
175  }
176 
177  return false;
178 }
179 
181  B.setInstrAndDebugLoc(MI);
182 
183  const LLT S32 = LLT::scalar(32);
184 
185  Register DstReg = MI.getOperand(0).getReg();
186  Register SrcReg = MI.getOperand(1).getReg();
187  LLT Ty = MRI.getType(DstReg);
188  LLT SrcTy = MRI.getType(SrcReg);
189  if (SrcTy != S32)
190  SrcReg = B.buildAnyExtOrTrunc(S32, SrcReg).getReg(0);
191 
192  if (Ty == S32) {
193  B.buildInstr(AMDGPU::G_AMDGPU_CVT_F32_UBYTE0, {DstReg},
194  {SrcReg}, MI.getFlags());
195  } else {
196  auto Cvt0 = B.buildInstr(AMDGPU::G_AMDGPU_CVT_F32_UBYTE0, {S32},
197  {SrcReg}, MI.getFlags());
198  B.buildFPTrunc(DstReg, Cvt0, MI.getFlags());
199  }
200 
201  MI.eraseFromParent();
202 }
203 
205  MachineInstr &MI, CvtF32UByteMatchInfo &MatchInfo) {
206  Register SrcReg = MI.getOperand(1).getReg();
207 
208  // Look through G_ZEXT.
209  mi_match(SrcReg, MRI, m_GZExt(m_Reg(SrcReg)));
210 
211  Register Src0;
212  int64_t ShiftAmt;
213  bool IsShr = mi_match(SrcReg, MRI, m_GLShr(m_Reg(Src0), m_ICst(ShiftAmt)));
214  if (IsShr || mi_match(SrcReg, MRI, m_GShl(m_Reg(Src0), m_ICst(ShiftAmt)))) {
215  const unsigned Offset = MI.getOpcode() - AMDGPU::G_AMDGPU_CVT_F32_UBYTE0;
216 
217  unsigned ShiftOffset = 8 * Offset;
218  if (IsShr)
219  ShiftOffset += ShiftAmt;
220  else
221  ShiftOffset -= ShiftAmt;
222 
223  MatchInfo.CvtVal = Src0;
224  MatchInfo.ShiftOffset = ShiftOffset;
225  return ShiftOffset < 32 && ShiftOffset >= 8 && (ShiftOffset % 8) == 0;
226  }
227 
228  // TODO: Simplify demanded bits.
229  return false;
230 }
231 
233  MachineInstr &MI, const CvtF32UByteMatchInfo &MatchInfo) {
234  B.setInstrAndDebugLoc(MI);
235  unsigned NewOpc = AMDGPU::G_AMDGPU_CVT_F32_UBYTE0 + MatchInfo.ShiftOffset / 8;
236 
237  const LLT S32 = LLT::scalar(32);
238  Register CvtSrc = MatchInfo.CvtVal;
239  LLT SrcTy = MRI.getType(MatchInfo.CvtVal);
240  if (SrcTy != S32) {
241  assert(SrcTy.isScalar() && SrcTy.getSizeInBits() >= 8);
242  CvtSrc = B.buildAnyExt(S32, CvtSrc).getReg(0);
243  }
244 
245  assert(MI.getOpcode() != NewOpc);
246  B.buildInstr(NewOpc, {MI.getOperand(0)}, {CvtSrc}, MI.getFlags());
247  MI.eraseFromParent();
248 }
249 
252  const SITargetLowering *TLI = static_cast<const SITargetLowering *>(
253  MF.getSubtarget().getTargetLowering());
254  Reg = MI.getOperand(1).getReg();
255  return TLI->isCanonicalized(Reg, MF);
256 }
257 
259 protected:
262 
263 public:
265  CombinerHelper &Helper,
266  AMDGPUPostLegalizerCombinerHelper &PostLegalizerHelper)
267  : Helper(Helper), PostLegalizerHelper(PostLegalizerHelper) {}
268 };
269 
270 #define AMDGPUPOSTLEGALIZERCOMBINERHELPER_GENCOMBINERHELPER_DEPS
271 #include "AMDGPUGenPostLegalizeGICombiner.inc"
272 #undef AMDGPUPOSTLEGALIZERCOMBINERHELPER_GENCOMBINERHELPER_DEPS
273 
274 namespace {
275 #define AMDGPUPOSTLEGALIZERCOMBINERHELPER_GENCOMBINERHELPER_H
276 #include "AMDGPUGenPostLegalizeGICombiner.inc"
277 #undef AMDGPUPOSTLEGALIZERCOMBINERHELPER_GENCOMBINERHELPER_H
278 
279 class AMDGPUPostLegalizerCombinerInfo final : public CombinerInfo {
280  GISelKnownBits *KB;
282 
283 public:
284  AMDGPUGenPostLegalizerCombinerHelperRuleConfig GeneratedRuleCfg;
285 
286  AMDGPUPostLegalizerCombinerInfo(bool EnableOpt, bool OptSize, bool MinSize,
287  const AMDGPULegalizerInfo *LI,
289  : CombinerInfo(/*AllowIllegalOps*/ false, /*ShouldLegalizeIllegal*/ true,
290  /*LegalizerInfo*/ LI, EnableOpt, OptSize, MinSize),
291  KB(KB), MDT(MDT) {
292  if (!GeneratedRuleCfg.parseCommandLineOption())
293  report_fatal_error("Invalid rule identifier");
294  }
295 
296  bool combine(GISelChangeObserver &Observer, MachineInstr &MI,
297  MachineIRBuilder &B) const override;
298 };
299 
301  MachineInstr &MI,
302  MachineIRBuilder &B) const {
303  CombinerHelper Helper(Observer, B, KB, MDT, LInfo);
304  AMDGPUPostLegalizerCombinerHelper PostLegalizerHelper(B, Helper);
305  AMDGPUGenPostLegalizerCombinerHelper Generated(GeneratedRuleCfg, Helper,
306  PostLegalizerHelper);
307 
308  if (Generated.tryCombineAll(Observer, MI, B))
309  return true;
310 
311  switch (MI.getOpcode()) {
312  case TargetOpcode::G_SHL:
313  case TargetOpcode::G_LSHR:
314  case TargetOpcode::G_ASHR:
315  // On some subtargets, 64-bit shift is a quarter rate instruction. In the
316  // common case, splitting this into a move and a 32-bit shift is faster and
317  // the same code size.
318  return Helper.tryCombineShiftToUnmerge(MI, 32);
319  }
320 
321  return false;
322 }
323 
324 #define AMDGPUPOSTLEGALIZERCOMBINERHELPER_GENCOMBINERHELPER_CPP
325 #include "AMDGPUGenPostLegalizeGICombiner.inc"
326 #undef AMDGPUPOSTLEGALIZERCOMBINERHELPER_GENCOMBINERHELPER_CPP
327 
328 // Pass boilerplate
329 // ================
330 
331 class AMDGPUPostLegalizerCombiner : public MachineFunctionPass {
332 public:
333  static char ID;
334 
335  AMDGPUPostLegalizerCombiner(bool IsOptNone = false);
336 
337  StringRef getPassName() const override {
338  return "AMDGPUPostLegalizerCombiner";
339  }
340 
341  bool runOnMachineFunction(MachineFunction &MF) override;
342 
343  void getAnalysisUsage(AnalysisUsage &AU) const override;
344 private:
345  bool IsOptNone;
346 };
347 } // end anonymous namespace
348 
349 void AMDGPUPostLegalizerCombiner::getAnalysisUsage(AnalysisUsage &AU) const {
351  AU.setPreservesCFG();
355  if (!IsOptNone) {
358  }
360 }
361 
362 AMDGPUPostLegalizerCombiner::AMDGPUPostLegalizerCombiner(bool IsOptNone)
363  : MachineFunctionPass(ID), IsOptNone(IsOptNone) {
364  initializeAMDGPUPostLegalizerCombinerPass(*PassRegistry::getPassRegistry());
365 }
366 
367 bool AMDGPUPostLegalizerCombiner::runOnMachineFunction(MachineFunction &MF) {
368  if (MF.getProperties().hasProperty(
369  MachineFunctionProperties::Property::FailedISel))
370  return false;
371  auto *TPC = &getAnalysis<TargetPassConfig>();
372  const Function &F = MF.getFunction();
373  bool EnableOpt =
374  MF.getTarget().getOptLevel() != CodeGenOpt::None && !skipFunction(F);
375 
376  const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
377  const AMDGPULegalizerInfo *LI
378  = static_cast<const AMDGPULegalizerInfo *>(ST.getLegalizerInfo());
379 
380  GISelKnownBits *KB = &getAnalysis<GISelKnownBitsAnalysis>().get(MF);
381  MachineDominatorTree *MDT =
382  IsOptNone ? nullptr : &getAnalysis<MachineDominatorTree>();
383  AMDGPUPostLegalizerCombinerInfo PCInfo(EnableOpt, F.hasOptSize(),
384  F.hasMinSize(), LI, KB, MDT);
385  Combiner C(PCInfo, TPC);
386  return C.combineMachineInstrs(MF, /*CSEInfo*/ nullptr);
387 }
388 
390 INITIALIZE_PASS_BEGIN(AMDGPUPostLegalizerCombiner, DEBUG_TYPE,
391  "Combine AMDGPU machine instrs after legalization",
392  false, false)
395 INITIALIZE_PASS_END(AMDGPUPostLegalizerCombiner, DEBUG_TYPE,
396  "Combine AMDGPU machine instrs after legalization", false,
397  false)
398 
399 namespace llvm {
401  return new AMDGPUPostLegalizerCombiner(IsOptNone);
402 }
403 } // end namespace llvm
MIPatternMatch.h
llvm::CmpInst::FCMP_ULE
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
Definition: InstrTypes.h:735
llvm::TargetMachine::getOptLevel
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
Definition: TargetMachine.cpp:198
CombinerInfo.h
llvm::MachineFunctionProperties::hasProperty
bool hasProperty(Property P) const
Definition: MachineFunction.h:165
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:102
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
llvm::initializeAMDGPUPostLegalizerCombinerPass
void initializeAMDGPUPostLegalizerCombinerPass(PassRegistry &)
llvm::CmpInst::Predicate
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:720
llvm::MIPatternMatch::m_Reg
operand_type_match m_Reg()
Definition: MIPatternMatch.h:127
llvm::GISelKnownBits
Definition: GISelKnownBits.h:29
llvm::MIPatternMatch::m_GShl
BinaryOp_match< LHS, RHS, TargetOpcode::G_SHL, false > m_GShl(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:357
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:52
AMDGPUPostLegalizerCombinerHelper::matchCvtF32UByteN
bool matchCvtF32UByteN(MachineInstr &MI, CvtF32UByteMatchInfo &MatchInfo)
Definition: AMDGPUPostLegalizerCombiner.cpp:204
llvm::Function
Definition: Function.h:61
AMDGPUPostLegalizerCombinerHelper::FMinFMaxLegacyInfo
Definition: AMDGPUPostLegalizerCombiner.cpp:43
llvm::MIPatternMatch::m_GLShr
BinaryOp_match< LHS, RHS, TargetOpcode::G_LSHR, false > m_GLShr(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:363
AMDGPUPostLegalizerCombinerHelperState::AMDGPUPostLegalizerCombinerHelperState
AMDGPUPostLegalizerCombinerHelperState(CombinerHelper &Helper, AMDGPUPostLegalizerCombinerHelper &PostLegalizerHelper)
Definition: AMDGPUPostLegalizerCombiner.cpp:264
AMDGPUPostLegalizerCombinerHelperState
Definition: AMDGPUPostLegalizerCombiner.cpp:258
AMDGPUPostLegalizerCombinerHelperState::Helper
CombinerHelper & Helper
Definition: AMDGPUPostLegalizerCombiner.cpp:260
llvm::CmpInst::FCMP_ONE
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
Definition: InstrTypes.h:728
GISelKnownBits.h
llvm::MachineFunctionPass
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Definition: MachineFunctionPass.h:30
llvm::createAMDGPUPostLegalizeCombiner
FunctionPass * createAMDGPUPostLegalizeCombiner(bool IsOptNone)
Definition: AMDGPUPostLegalizerCombiner.cpp:400
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::getSelectionDAGFallbackAnalysisUsage
void getSelectionDAGFallbackAnalysisUsage(AnalysisUsage &AU)
Modify analysis usage so it preserves passes required for the SelectionDAG fallback.
Definition: Utils.cpp:762
llvm::GCNSubtarget
Definition: GCNSubtarget.h:38
llvm::CombinerInfo
Definition: CombinerInfo.h:27
llvm::CmpInst::FCMP_OGT
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
Definition: InstrTypes.h:724
llvm::BitmaskEnumDetail::Mask
std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
llvm::MachineFunctionPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition: MachineFunctionPass.cpp:102
llvm::AMDGPULegalizerInfo
This class provides the information for the target register banks.
Definition: AMDGPULegalizerInfo.h:32
AMDGPUPostLegalizerCombinerHelper::matchRemoveFcanonicalize
bool matchRemoveFcanonicalize(MachineInstr &MI, Register &Reg)
Definition: AMDGPUPostLegalizerCombiner.cpp:250
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::CmpInst::FCMP_ULT
@ FCMP_ULT
1 1 0 0 True if unordered or less than
Definition: InstrTypes.h:734
INITIALIZE_PASS_BEGIN
INITIALIZE_PASS_BEGIN(AMDGPUPostLegalizerCombiner, DEBUG_TYPE, "Combine AMDGPU machine instrs after legalization", false, false) INITIALIZE_PASS_END(AMDGPUPostLegalizerCombiner
llvm::GISelKnownBitsAnalysis
To use KnownBitsInfo analysis in a pass, KnownBitsInfo &Info = getAnalysis<GISelKnownBitsInfoAnalysis...
Definition: GISelKnownBits.h:113
TargetMachine.h
llvm::MIPatternMatch::m_GZExt
UnaryOp_match< SrcTy, TargetOpcode::G_ZEXT > m_GZExt(const SrcTy &Src)
Definition: MIPatternMatch.h:414
GCNSubtarget.h
AMDGPUPostLegalizerCombinerHelper::applyUCharToFloat
void applyUCharToFloat(MachineInstr &MI)
Definition: AMDGPUPostLegalizerCombiner.cpp:180
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::LLT::getSizeInBits
TypeSize getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
Definition: LowLevelTypeImpl.h:153
Y
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::CmpInst::FCMP_UGE
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
Definition: InstrTypes.h:733
llvm::MachineFunction::getProperties
const MachineFunctionProperties & getProperties() const
Get the function properties.
Definition: MachineFunction.h:713
false
Definition: StackSlotColoring.cpp:142
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::CmpInst::FCMP_UNO
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
Definition: InstrTypes.h:730
AMDGPUPostLegalizerCombinerHelper::applyCvtF32UByteN
void applyCvtF32UByteN(MachineInstr &MI, const CvtF32UByteMatchInfo &MatchInfo)
Definition: AMDGPUPostLegalizerCombiner.cpp:232
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:140
llvm::APInt::getHighBitsSet
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Get a value with high bits set.
Definition: APInt.h:655
AMDGPUPostLegalizerCombinerHelperState::PostLegalizerHelper
AMDGPUPostLegalizerCombinerHelper & PostLegalizerHelper
Definition: AMDGPUPostLegalizerCombiner.cpp:261
DEBUG_TYPE
#define DEBUG_TYPE
Definition: AMDGPUPostLegalizerCombiner.cpp:27
llvm::CmpInst::FCMP_OEQ
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
Definition: InstrTypes.h:723
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::CombinerHelper
Definition: CombinerHelper.h:90
llvm::CmpInst::FCMP_OLT
@ FCMP_OLT
0 1 0 0 True if ordered and less than
Definition: InstrTypes.h:726
llvm::MIPatternMatch::m_Pred
bind_ty< CmpInst::Predicate > m_Pred(CmpInst::Predicate &P)
Definition: MIPatternMatch.h:229
llvm::None
const NoneType None
Definition: None.h:23
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
AMDGPUPostLegalizerCombinerHelper::matchUCharToFloat
bool matchUCharToFloat(MachineInstr &MI)
Definition: AMDGPUPostLegalizerCombiner.cpp:161
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:58
llvm::CmpInst::FCMP_FALSE
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
Definition: InstrTypes.h:722
llvm::TargetPassConfig
Target-Independent Code Generator Pass Configuration Options.
Definition: TargetPassConfig.h:84
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:622
AMDGPUPostLegalizerCombinerHelper::FMinFMaxLegacyInfo::False
Register False
Definition: AMDGPUPostLegalizerCombiner.cpp:47
Combine
Hexagon Vector Combine
Definition: HexagonVectorCombine.cpp:1520
AMDGPUMCTargetDesc.h
llvm::MachineIRBuilder
Helper class to build MachineInstr.
Definition: MachineIRBuilder.h:212
AMDGPUPostLegalizerCombinerHelper::AMDGPUPostLegalizerCombinerHelper
AMDGPUPostLegalizerCombinerHelper(MachineIRBuilder &B, CombinerHelper &Helper)
Definition: AMDGPUPostLegalizerCombiner.cpp:40
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:64
llvm::Combiner
Definition: Combiner.h:27
AMDGPUPostLegalizerCombinerHelper::matchFMinFMaxLegacy
bool matchFMinFMaxLegacy(MachineInstr &MI, FMinFMaxLegacyInfo &Info)
Definition: AMDGPUPostLegalizerCombiner.cpp:73
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
INITIALIZE_PASS_DEPENDENCY
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
TargetPassConfig.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::CmpInst::FCMP_OGE
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
Definition: InstrTypes.h:725
AMDGPUPostLegalizerCombinerHelper::Helper
CombinerHelper & Helper
Definition: AMDGPUPostLegalizerCombiner.cpp:37
llvm::LLT::isScalar
bool isScalar() const
Definition: LowLevelTypeImpl.h:119
llvm::AMDGPUSubtarget::hasFminFmaxLegacy
bool hasFminFmaxLegacy() const
Definition: AMDGPUSubtarget.h:173
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:70
llvm::MachineFunction
Definition: MachineFunction.h:230
CombinerHelper.h
AMDGPUPostLegalizerCombinerHelper::MF
MachineFunction & MF
Definition: AMDGPUPostLegalizerCombiner.cpp:35
AMDGPUPostLegalizerCombinerHelper::FMinFMaxLegacyInfo::Pred
CmpInst::Predicate Pred
Definition: AMDGPUPostLegalizerCombiner.cpp:48
Cond
SmallVector< MachineOperand, 4 > Cond
Definition: BasicBlockSections.cpp:179
llvm::AnalysisUsage::setPreservesCFG
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition: Pass.cpp:253
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
AMDGPU.h
llvm::MachineRegisterInfo::hasOneNonDBGUse
bool hasOneNonDBGUse(Register RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register.
Definition: MachineRegisterInfo.cpp:419
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::AnalysisUsage::addPreserved
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
Definition: PassAnalysisSupport.h:98
Combiner.h
AMDGPUPostLegalizerCombinerHelper::applySelectFCmpToFMinToFMaxLegacy
void applySelectFCmpToFMinToFMaxLegacy(MachineInstr &MI, const FMinFMaxLegacyInfo &Info)
Definition: AMDGPUPostLegalizerCombiner.cpp:112
llvm::GISelChangeObserver
Abstract class that contains various methods for clients to notify about changes.
Definition: GISelChangeObserver.h:29
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::CmpInst::FCMP_UGT
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
Definition: InstrTypes.h:732
AMDGPUPostLegalizerCombinerHelper::B
MachineIRBuilder & B
Definition: AMDGPUPostLegalizerCombiner.cpp:34
AMDGPUPostLegalizerCombinerHelper::FMinFMaxLegacyInfo::True
Register True
Definition: AMDGPUPostLegalizerCombiner.cpp:46
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition: MachineFunction.h:588
llvm::MIPatternMatch::m_GFCmp
CompareOp_match< Pred, LHS, RHS, TargetOpcode::G_FCMP > m_GFCmp(const Pred &P, const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:502
AMDGPUPostLegalizerCombinerHelper::CvtF32UByteMatchInfo::ShiftOffset
unsigned ShiftOffset
Definition: AMDGPUPostLegalizerCombiner.cpp:63
llvm::MachineFunction::getTarget
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Definition: MachineFunction.h:618
llvm::SITargetLowering
Definition: SIISelLowering.h:30
legalization
Combine AMDGPU machine instrs after legalization
Definition: AMDGPUPostLegalizerCombiner.cpp:396
AMDGPUPostLegalizerCombinerHelper
Definition: AMDGPUPostLegalizerCombiner.cpp:32
AMDGPUPostLegalizerCombinerHelper::FMinFMaxLegacyInfo::RHS
Register RHS
Definition: AMDGPUPostLegalizerCombiner.cpp:45
AMDGPUPostLegalizerCombinerHelper::CvtF32UByteMatchInfo::CvtVal
Register CvtVal
Definition: AMDGPUPostLegalizerCombiner.cpp:62
llvm::MIPatternMatch::m_ICst
ConstantMatch m_ICst(int64_t &Cst)
Definition: MIPatternMatch.h:74
AMDGPUPostLegalizerCombinerHelper::MRI
MachineRegisterInfo & MRI
Definition: AMDGPUPostLegalizerCombiner.cpp:36
AMDGPUPostLegalizerCombinerHelper::FMinFMaxLegacyInfo::LHS
Register LHS
Definition: AMDGPUPostLegalizerCombiner.cpp:44
AMDGPULegalizerInfo.h
llvm::MachineRegisterInfo::getType
LLT getType(Register Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register.
Definition: MachineRegisterInfo.h:732
llvm::CmpInst::FCMP_UNE
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
Definition: InstrTypes.h:736
AMDGPUPostLegalizerCombinerHelper::CvtF32UByteMatchInfo
Definition: AMDGPUPostLegalizerCombiner.cpp:61
llvm::CmpInst::FCMP_OLE
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
Definition: InstrTypes.h:727
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
llvm::MIPatternMatch::mi_match
bool mi_match(Reg R, const MachineRegisterInfo &MRI, Pattern &&P)
Definition: MIPatternMatch.h:24
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition: PassAnalysisSupport.h:75
llvm::MachineDominatorTree
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Definition: MachineDominators.h:45
combine
vector combine
Definition: VectorCombine.cpp:1029
llvm::CmpInst::FCMP_TRUE
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
Definition: InstrTypes.h:737
llvm::LLT::scalar
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
Definition: LowLevelTypeImpl.h:43
llvm::CmpInst::FCMP_ORD
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
Definition: InstrTypes.h:729
llvm::SITargetLowering::isCanonicalized
bool isCanonicalized(SelectionDAG &DAG, SDValue Op, unsigned MaxDepth=5) const
Definition: SIISelLowering.cpp:9509
llvm::CmpInst::FCMP_UEQ
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
Definition: InstrTypes.h:731
machine
coro Split coroutine into a set of functions driving its state machine
Definition: CoroSplit.cpp:2280
MachineDominators.h
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::LLT
Definition: LowLevelTypeImpl.h:40