LLVM 17.0.0git
Float2Int.cpp
Go to the documentation of this file.
1//===- Float2Int.cpp - Demote floating point ops to work on integers ------===//
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 file implements the Float2Int pass, which aims to demote floating
10// point operations to work on integers, where that is losslessly possible.
11//
12//===----------------------------------------------------------------------===//
13
15#include "llvm/ADT/APInt.h"
16#include "llvm/ADT/APSInt.h"
19#include "llvm/IR/Constants.h"
20#include "llvm/IR/Dominators.h"
21#include "llvm/IR/IRBuilder.h"
22#include "llvm/IR/Module.h"
24#include "llvm/Pass.h"
26#include "llvm/Support/Debug.h"
29#include <deque>
30
31#define DEBUG_TYPE "float2int"
32
33using namespace llvm;
34
35// The algorithm is simple. Start at instructions that convert from the
36// float to the int domain: fptoui, fptosi and fcmp. Walk up the def-use
37// graph, using an equivalence datastructure to unify graphs that interfere.
38//
39// Mappable instructions are those with an integer corrollary that, given
40// integer domain inputs, produce an integer output; fadd, for example.
41//
42// If a non-mappable instruction is seen, this entire def-use graph is marked
43// as non-transformable. If we see an instruction that converts from the
44// integer domain to FP domain (uitofp,sitofp), we terminate our walk.
45
46/// The largest integer type worth dealing with.
48MaxIntegerBW("float2int-max-integer-bw", cl::init(64), cl::Hidden,
49 cl::desc("Max integer bitwidth to consider in float2int"
50 "(default=64)"));
51
52// Given a FCmp predicate, return a matching ICmp predicate if one
53// exists, otherwise return BAD_ICMP_PREDICATE.
55 switch (P) {
58 return CmpInst::ICMP_EQ;
61 return CmpInst::ICMP_SGT;
64 return CmpInst::ICMP_SGE;
67 return CmpInst::ICMP_SLT;
70 return CmpInst::ICMP_SLE;
73 return CmpInst::ICMP_NE;
74 default:
76 }
77}
78
79// Given a floating point binary operator, return the matching
80// integer version.
81static Instruction::BinaryOps mapBinOpcode(unsigned Opcode) {
82 switch (Opcode) {
83 default: llvm_unreachable("Unhandled opcode!");
84 case Instruction::FAdd: return Instruction::Add;
85 case Instruction::FSub: return Instruction::Sub;
86 case Instruction::FMul: return Instruction::Mul;
87 }
88}
89
90// Find the roots - instructions that convert from the FP domain to
91// integer domain.
92void Float2IntPass::findRoots(Function &F, const DominatorTree &DT) {
93 for (BasicBlock &BB : F) {
94 // Unreachable code can take on strange forms that we are not prepared to
95 // handle. For example, an instruction may have itself as an operand.
96 if (!DT.isReachableFromEntry(&BB))
97 continue;
98
99 for (Instruction &I : BB) {
100 if (isa<VectorType>(I.getType()))
101 continue;
102 switch (I.getOpcode()) {
103 default: break;
104 case Instruction::FPToUI:
105 case Instruction::FPToSI:
106 Roots.insert(&I);
107 break;
108 case Instruction::FCmp:
109 if (mapFCmpPred(cast<CmpInst>(&I)->getPredicate()) !=
111 Roots.insert(&I);
112 break;
113 }
114 }
115 }
116}
117
118// Helper - mark I as having been traversed, having range R.
119void Float2IntPass::seen(Instruction *I, ConstantRange R) {
120 LLVM_DEBUG(dbgs() << "F2I: " << *I << ":" << R << "\n");
121 auto IT = SeenInsts.find(I);
122 if (IT != SeenInsts.end())
123 IT->second = std::move(R);
124 else
125 SeenInsts.insert(std::make_pair(I, std::move(R)));
126}
127
128// Helper - get a range representing a poison value.
129ConstantRange Float2IntPass::badRange() {
130 return ConstantRange::getFull(MaxIntegerBW + 1);
131}
132ConstantRange Float2IntPass::unknownRange() {
133 return ConstantRange::getEmpty(MaxIntegerBW + 1);
134}
135ConstantRange Float2IntPass::validateRange(ConstantRange R) {
136 if (R.getBitWidth() > MaxIntegerBW + 1)
137 return badRange();
138 return R;
139}
140
141// The most obvious way to structure the search is a depth-first, eager
142// search from each root. However, that require direct recursion and so
143// can only handle small instruction sequences. Instead, we split the search
144// up into two phases:
145// - walkBackwards: A breadth-first walk of the use-def graph starting from
146// the roots. Populate "SeenInsts" with interesting
147// instructions and poison values if they're obvious and
148// cheap to compute. Calculate the equivalance set structure
149// while we're here too.
150// - walkForwards: Iterate over SeenInsts in reverse order, so we visit
151// defs before their uses. Calculate the real range info.
152
153// Breadth-first walk of the use-def graph; determine the set of nodes
154// we care about and eagerly determine if some of them are poisonous.
155void Float2IntPass::walkBackwards() {
156 std::deque<Instruction*> Worklist(Roots.begin(), Roots.end());
157 while (!Worklist.empty()) {
158 Instruction *I = Worklist.back();
159 Worklist.pop_back();
160
161 if (SeenInsts.contains(I))
162 // Seen already.
163 continue;
164
165 switch (I->getOpcode()) {
166 // FIXME: Handle select and phi nodes.
167 default:
168 // Path terminated uncleanly.
169 seen(I, badRange());
170 break;
171
172 case Instruction::UIToFP:
173 case Instruction::SIToFP: {
174 // Path terminated cleanly - use the type of the integer input to seed
175 // the analysis.
176 unsigned BW = I->getOperand(0)->getType()->getPrimitiveSizeInBits();
177 auto Input = ConstantRange::getFull(BW);
178 auto CastOp = (Instruction::CastOps)I->getOpcode();
179 seen(I, validateRange(Input.castOp(CastOp, MaxIntegerBW+1)));
180 continue;
181 }
182
183 case Instruction::FNeg:
184 case Instruction::FAdd:
185 case Instruction::FSub:
186 case Instruction::FMul:
187 case Instruction::FPToUI:
188 case Instruction::FPToSI:
189 case Instruction::FCmp:
190 seen(I, unknownRange());
191 break;
192 }
193
194 for (Value *O : I->operands()) {
195 if (Instruction *OI = dyn_cast<Instruction>(O)) {
196 // Unify def-use chains if they interfere.
197 ECs.unionSets(I, OI);
198 if (SeenInsts.find(I)->second != badRange())
199 Worklist.push_back(OI);
200 } else if (!isa<ConstantFP>(O)) {
201 // Not an instruction or ConstantFP? we can't do anything.
202 seen(I, badRange());
203 }
204 }
205 }
206}
207
208// Calculate result range from operand ranges.
209// Return std::nullopt if the range cannot be calculated yet.
210std::optional<ConstantRange> Float2IntPass::calcRange(Instruction *I) {
212 for (Value *O : I->operands()) {
213 if (Instruction *OI = dyn_cast<Instruction>(O)) {
214 auto OpIt = SeenInsts.find(OI);
215 assert(OpIt != SeenInsts.end() && "def not seen before use!");
216 if (OpIt->second == unknownRange())
217 return std::nullopt; // Wait until operand range has been calculated.
218 OpRanges.push_back(OpIt->second);
219 } else if (ConstantFP *CF = dyn_cast<ConstantFP>(O)) {
220 // Work out if the floating point number can be losslessly represented
221 // as an integer.
222 // APFloat::convertToInteger(&Exact) purports to do what we want, but
223 // the exactness can be too precise. For example, negative zero can
224 // never be exactly converted to an integer.
225 //
226 // Instead, we ask APFloat to round itself to an integral value - this
227 // preserves sign-of-zero - then compare the result with the original.
228 //
229 const APFloat &F = CF->getValueAPF();
230
231 // First, weed out obviously incorrect values. Non-finite numbers
232 // can't be represented and neither can negative zero, unless
233 // we're in fast math mode.
234 if (!F.isFinite() ||
235 (F.isZero() && F.isNegative() && isa<FPMathOperator>(I) &&
236 !I->hasNoSignedZeros()))
237 return badRange();
238
239 APFloat NewF = F;
241 if (Res != APFloat::opOK || NewF != F)
242 return badRange();
243
244 // OK, it's representable. Now get it.
245 APSInt Int(MaxIntegerBW+1, false);
246 bool Exact;
247 CF->getValueAPF().convertToInteger(Int,
249 &Exact);
250 OpRanges.push_back(ConstantRange(Int));
251 } else {
252 llvm_unreachable("Should have already marked this as badRange!");
253 }
254 }
255
256 switch (I->getOpcode()) {
257 // FIXME: Handle select and phi nodes.
258 default:
259 case Instruction::UIToFP:
260 case Instruction::SIToFP:
261 llvm_unreachable("Should have been handled in walkForwards!");
262
263 case Instruction::FNeg: {
264 assert(OpRanges.size() == 1 && "FNeg is a unary operator!");
265 unsigned Size = OpRanges[0].getBitWidth();
267 return Zero.sub(OpRanges[0]);
268 }
269
270 case Instruction::FAdd:
271 case Instruction::FSub:
272 case Instruction::FMul: {
273 assert(OpRanges.size() == 2 && "its a binary operator!");
274 auto BinOp = (Instruction::BinaryOps) I->getOpcode();
275 return OpRanges[0].binaryOp(BinOp, OpRanges[1]);
276 }
277
278 //
279 // Root-only instructions - we'll only see these if they're the
280 // first node in a walk.
281 //
282 case Instruction::FPToUI:
283 case Instruction::FPToSI: {
284 assert(OpRanges.size() == 1 && "FPTo[US]I is a unary operator!");
285 // Note: We're ignoring the casts output size here as that's what the
286 // caller expects.
287 auto CastOp = (Instruction::CastOps)I->getOpcode();
288 return OpRanges[0].castOp(CastOp, MaxIntegerBW+1);
289 }
290
291 case Instruction::FCmp:
292 assert(OpRanges.size() == 2 && "FCmp is a binary operator!");
293 return OpRanges[0].unionWith(OpRanges[1]);
294 }
295}
296
297// Walk forwards down the list of seen instructions, so we visit defs before
298// uses.
299void Float2IntPass::walkForwards() {
300 std::deque<Instruction *> Worklist;
301 for (const auto &Pair : SeenInsts)
302 if (Pair.second == unknownRange())
303 Worklist.push_back(Pair.first);
304
305 while (!Worklist.empty()) {
306 Instruction *I = Worklist.back();
307 Worklist.pop_back();
308
309 if (std::optional<ConstantRange> Range = calcRange(I))
310 seen(I, *Range);
311 else
312 Worklist.push_front(I); // Reprocess later.
313 }
314}
315
316// If there is a valid transform to be done, do it.
317bool Float2IntPass::validateAndTransform() {
318 bool MadeChange = false;
319
320 // Iterate over every disjoint partition of the def-use graph.
321 for (auto It = ECs.begin(), E = ECs.end(); It != E; ++It) {
322 ConstantRange R(MaxIntegerBW + 1, false);
323 bool Fail = false;
324 Type *ConvertedToTy = nullptr;
325
326 // For every member of the partition, union all the ranges together.
327 for (auto MI = ECs.member_begin(It), ME = ECs.member_end();
328 MI != ME; ++MI) {
329 Instruction *I = *MI;
330 auto SeenI = SeenInsts.find(I);
331 if (SeenI == SeenInsts.end())
332 continue;
333
334 R = R.unionWith(SeenI->second);
335 // We need to ensure I has no users that have not been seen.
336 // If it does, transformation would be illegal.
337 //
338 // Don't count the roots, as they terminate the graphs.
339 if (!Roots.contains(I)) {
340 // Set the type of the conversion while we're here.
341 if (!ConvertedToTy)
342 ConvertedToTy = I->getType();
343 for (User *U : I->users()) {
344 Instruction *UI = dyn_cast<Instruction>(U);
345 if (!UI || !SeenInsts.contains(UI)) {
346 LLVM_DEBUG(dbgs() << "F2I: Failing because of " << *U << "\n");
347 Fail = true;
348 break;
349 }
350 }
351 }
352 if (Fail)
353 break;
354 }
355
356 // If the set was empty, or we failed, or the range is poisonous,
357 // bail out.
358 if (ECs.member_begin(It) == ECs.member_end() || Fail ||
359 R.isFullSet() || R.isSignWrappedSet())
360 continue;
361 assert(ConvertedToTy && "Must have set the convertedtoty by this point!");
362
363 // The number of bits required is the maximum of the upper and
364 // lower limits, plus one so it can be signed.
365 unsigned MinBW = std::max(R.getLower().getSignificantBits(),
366 R.getUpper().getSignificantBits()) +
367 1;
368 LLVM_DEBUG(dbgs() << "F2I: MinBitwidth=" << MinBW << ", R: " << R << "\n");
369
370 // If we've run off the realms of the exactly representable integers,
371 // the floating point result will differ from an integer approximation.
372
373 // Do we need more bits than are in the mantissa of the type we converted
374 // to? semanticsPrecision returns the number of mantissa bits plus one
375 // for the sign bit.
376 unsigned MaxRepresentableBits
377 = APFloat::semanticsPrecision(ConvertedToTy->getFltSemantics()) - 1;
378 if (MinBW > MaxRepresentableBits) {
379 LLVM_DEBUG(dbgs() << "F2I: Value not guaranteed to be representable!\n");
380 continue;
381 }
382 if (MinBW > 64) {
384 dbgs() << "F2I: Value requires more than 64 bits to represent!\n");
385 continue;
386 }
387
388 // OK, R is known to be representable. Now pick a type for it.
389 // FIXME: Pick the smallest legal type that will fit.
390 Type *Ty = (MinBW > 32) ? Type::getInt64Ty(*Ctx) : Type::getInt32Ty(*Ctx);
391
392 for (auto MI = ECs.member_begin(It), ME = ECs.member_end();
393 MI != ME; ++MI)
394 convert(*MI, Ty);
395 MadeChange = true;
396 }
397
398 return MadeChange;
399}
400
401Value *Float2IntPass::convert(Instruction *I, Type *ToTy) {
402 if (ConvertedInsts.contains(I))
403 // Already converted this instruction.
404 return ConvertedInsts[I];
405
406 SmallVector<Value*,4> NewOperands;
407 for (Value *V : I->operands()) {
408 // Don't recurse if we're an instruction that terminates the path.
409 if (I->getOpcode() == Instruction::UIToFP ||
410 I->getOpcode() == Instruction::SIToFP) {
411 NewOperands.push_back(V);
412 } else if (Instruction *VI = dyn_cast<Instruction>(V)) {
413 NewOperands.push_back(convert(VI, ToTy));
414 } else if (ConstantFP *CF = dyn_cast<ConstantFP>(V)) {
415 APSInt Val(ToTy->getPrimitiveSizeInBits(), /*isUnsigned=*/false);
416 bool Exact;
417 CF->getValueAPF().convertToInteger(Val,
419 &Exact);
420 NewOperands.push_back(ConstantInt::get(ToTy, Val));
421 } else {
422 llvm_unreachable("Unhandled operand type?");
423 }
424 }
425
426 // Now create a new instruction.
427 IRBuilder<> IRB(I);
428 Value *NewV = nullptr;
429 switch (I->getOpcode()) {
430 default: llvm_unreachable("Unhandled instruction!");
431
432 case Instruction::FPToUI:
433 NewV = IRB.CreateZExtOrTrunc(NewOperands[0], I->getType());
434 break;
435
436 case Instruction::FPToSI:
437 NewV = IRB.CreateSExtOrTrunc(NewOperands[0], I->getType());
438 break;
439
440 case Instruction::FCmp: {
441 CmpInst::Predicate P = mapFCmpPred(cast<CmpInst>(I)->getPredicate());
442 assert(P != CmpInst::BAD_ICMP_PREDICATE && "Unhandled predicate!");
443 NewV = IRB.CreateICmp(P, NewOperands[0], NewOperands[1], I->getName());
444 break;
445 }
446
447 case Instruction::UIToFP:
448 NewV = IRB.CreateZExtOrTrunc(NewOperands[0], ToTy);
449 break;
450
451 case Instruction::SIToFP:
452 NewV = IRB.CreateSExtOrTrunc(NewOperands[0], ToTy);
453 break;
454
455 case Instruction::FNeg:
456 NewV = IRB.CreateNeg(NewOperands[0], I->getName());
457 break;
458
459 case Instruction::FAdd:
460 case Instruction::FSub:
461 case Instruction::FMul:
462 NewV = IRB.CreateBinOp(mapBinOpcode(I->getOpcode()),
463 NewOperands[0], NewOperands[1],
464 I->getName());
465 break;
466 }
467
468 // If we're a root instruction, RAUW.
469 if (Roots.count(I))
470 I->replaceAllUsesWith(NewV);
471
472 ConvertedInsts[I] = NewV;
473 return NewV;
474}
475
476// Perform dead code elimination on the instructions we just modified.
477void Float2IntPass::cleanup() {
478 for (auto &I : reverse(ConvertedInsts))
479 I.first->eraseFromParent();
480}
481
483 LLVM_DEBUG(dbgs() << "F2I: Looking at function " << F.getName() << "\n");
484 // Clear out all state.
486 SeenInsts.clear();
487 ConvertedInsts.clear();
488 Roots.clear();
489
490 Ctx = &F.getParent()->getContext();
491
492 findRoots(F, DT);
493
494 walkBackwards();
495 walkForwards();
496
497 bool Modified = validateAndTransform();
498 if (Modified)
499 cleanup();
500 return Modified;
501}
502
505 if (!runImpl(F, DT))
506 return PreservedAnalyses::all();
507
510 return PA;
511}
#define Fail
This file implements a class to represent arbitrary precision integral constant values and operations...
This file implements the APSInt class, which is a simple class that represents an arbitrary sized int...
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
#define LLVM_DEBUG(X)
Definition: Debug.h:101
uint64_t Size
expand large fp convert
static CmpInst::Predicate mapFCmpPred(CmpInst::Predicate P)
Definition: Float2Int.cpp:54
static Instruction::BinaryOps mapBinOpcode(unsigned Opcode)
Definition: Float2Int.cpp:81
static cl::opt< unsigned > MaxIntegerBW("float2int-max-integer-bw", cl::init(64), cl::Hidden, cl::desc("Max integer bitwidth to consider in float2int" "(default=64)"))
The largest integer type worth dealing with.
This is the interface for a simple mod/ref and alias analysis over globals.
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
Module.h This file contains the declarations for the Module class.
#define P(N)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
opStatus roundToIntegral(roundingMode RM)
Definition: APFloat.h:1073
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
Definition: APInt.h:177
An arbitrary precision integer that knows its signedness.
Definition: APSInt.h:23
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:620
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:774
LLVM Basic Block Representation.
Definition: BasicBlock.h:56
Represents analyses that only rely on functions' control flow.
Definition: PassManager.h:113
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:718
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
Definition: InstrTypes.h:721
@ ICMP_SLT
signed less than
Definition: InstrTypes.h:747
@ ICMP_SLE
signed less or equal
Definition: InstrTypes.h:748
@ FCMP_OLT
0 1 0 0 True if ordered and less than
Definition: InstrTypes.h:724
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
Definition: InstrTypes.h:733
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
Definition: InstrTypes.h:722
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
Definition: InstrTypes.h:723
@ ICMP_SGT
signed greater than
Definition: InstrTypes.h:745
@ FCMP_ULT
1 1 0 0 True if unordered or less than
Definition: InstrTypes.h:732
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
Definition: InstrTypes.h:726
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
Definition: InstrTypes.h:729
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
Definition: InstrTypes.h:730
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
Definition: InstrTypes.h:725
@ ICMP_EQ
equal
Definition: InstrTypes.h:739
@ ICMP_NE
not equal
Definition: InstrTypes.h:740
@ ICMP_SGE
signed greater or equal
Definition: InstrTypes.h:746
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
Definition: InstrTypes.h:734
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
Definition: InstrTypes.h:731
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:260
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition: Constants.cpp:888
This class represents a range of values.
Definition: ConstantRange.h:47
Analysis pass which computes a DominatorTree.
Definition: Dominators.h:279
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:166
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
Definition: Dominators.cpp:321
EquivalenceClasses - This represents a collection of equivalence classes and supports three efficient...
bool runImpl(Function &F, const DominatorTree &DT)
Definition: Float2Int.cpp:482
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: Float2Int.cpp:503
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:2558
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:158
void preserveSet()
Mark an analysis set as preserved.
Definition: PassManager.h:188
size_t size() const
Definition: SmallVector.h:91
void push_back(const T &Elt)
Definition: SmallVector.h:416
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
const fltSemantics & getFltSemantics() const
static IntegerType * getInt32Ty(LLVMContext &C)
static IntegerType * getInt64Ty(LLVMContext &C)
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
LLVM Value Representation.
Definition: Value.h:74
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
Definition: PPCPredicates.h:87
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:445
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto reverse(ContainerTy &&C)
Definition: STLExtras.h:511
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
static constexpr roundingMode rmNearestTiesToEven
Definition: APFloat.h:217
static unsigned int semanticsPrecision(const fltSemantics &)
Definition: APFloat.cpp:289