[PATCH] D86393: [GISel] Add combines for unary FP instrs with constant operand

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 22 10:57:28 PDT 2020


arsenm added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:1481
+bool CombinerHelper::matchCombineConstantFoldFpUnary(MachineInstr &MI,
+                                                     double &Cst) {
+  Register DstReg = MI.getOperand(0).getReg();
----------------
mkitzan wrote:
> arsenm wrote:
> > Why go through double instead of preserving the APFloat?
> Because `GIDefMatchData` wants to have the variable uninitialized, which would call the default ctor of `APFloat` which is private.
> 
> See following pseudo code:
> ```
> APFLoat MatchDataN; // calls APFloat()
> if (matchCombineConstantFoldFpUnary(MI, MatchDataN))
>   replaceInstWithAPFloat(MI, MatchDataN); // dummy function for example
> ```
> 
> The error looks like:
> ```
> llvm-project/build/lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc:343:11: error: calling a private constructor of class 'llvm::APFloat'
>   APFloat MatchData23;
>           ^
> llvm-project/llvm/include/llvm/ADT/APFloat.h:842:3: note: implicitly declared private here
>   APFloat() : U(IEEEdouble()) {
>   ^
> ```
I guess you could work around this by keeping it wrapped in Optional<APFloat>


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86393/new/

https://reviews.llvm.org/D86393



More information about the llvm-commits mailing list