Lines Matching +full:depth +full:-
1 //===- lib/CodeGen/GlobalISel/GISelKnownBits.cpp --------------*- C++ *-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
26 #define DEBUG_TYPE "gisel-known-bits"
39 Align GISelKnownBits::computeKnownAlignment(Register R, unsigned Depth) {
41 switch (MI->getOpcode()) {
43 return computeKnownAlignment(MI->getOperand(1).getReg(), Depth);
46 return Align(MI->getOperand(2).getImm());
49 int FrameIdx = MI->getOperand(1).getIndex();
57 return TL.computeKnownAlignForTargetInstr(*this, R, MRI, Depth + 1);
78 unsigned Depth) {
83 computeKnownBitsImpl(R, Known, DemandedElts, Depth);
101 dumpResult(const MachineInstr &MI, const KnownBits &Known, unsigned Depth) {
102 dbgs() << "[" << Depth << "] Compute known bits: " << MI << "[" << Depth
103 << "] Computed for: " << MI << "[" << Depth << "] Known: 0x"
105 << "[" << Depth << "] Zero: 0x" << toString(Known.Zero, 16, false)
107 << "[" << Depth << "] One: 0x" << toString(Known.One, 16, false)
115 unsigned Depth) {
117 computeKnownBitsImpl(Src1, Known, DemandedElts, Depth);
124 computeKnownBitsImpl(Src0, Known2, DemandedElts, Depth);
146 unsigned Depth) {
163 Known = CacheEntry->second;
165 LLVM_DEBUG(dumpResult(MI, Known, Depth));
171 // Depth may get bigger than max depth if it gets passed to a different
174 // with some max depth, but then we hit TL.computeKnownBitsForTargetInstr
176 // depth. If we just check for equality, we would never exit if the depth
178 // already bigger than its max depth.
179 if (Depth >= getMaxDepth())
190 Depth);
195 for (unsigned i = 0, e = MI.getNumOperands() - 1; i < e; ++i) {
200 Depth + 1);
217 // point of the pipeline, otherwise the main live-range will be
236 // copies or phis of the form `%1:(s32) = OP %0:gpr32`, known-bits
244 // For COPYs we don't do anything, don't increase the depth.
246 Depth + (Opcode != TargetOpcode::COPY));
261 Known = KnownBits::makeConstant(MI.getOperand(1).getCImm()->getValue());
271 Depth + 1);
273 Depth + 1);
280 Depth + 1);
282 Depth + 1);
298 Depth + 1);
300 Depth + 1);
308 Depth + 1);
310 Depth + 1);
318 Depth + 1);
320 Depth + 1);
327 Depth + 1);
329 Depth + 1);
335 Known, DemandedElts, Depth + 1);
342 Depth + 1);
344 Depth + 1);
352 Depth + 1);
354 Depth + 1);
361 DemandedElts, Depth + 1);
363 DemandedElts, Depth + 1);
370 DemandedElts, Depth + 1);
372 DemandedElts, Depth + 1);
389 Depth + 1);
398 Depth + 1);
404 Depth + 1);
410 KnownBits KnownRange(MMO->getMemoryType().getScalarSizeInBits());
411 if (const MDNode *Ranges = MMO->getRanges())
421 KnownBits KnownRange(MMO->getMemoryType().getScalarSizeInBits());
422 if (const MDNode *Ranges = MMO->getRanges())
432 Depth + 1);
434 Depth + 1);
441 Depth + 1);
443 Depth + 1);
450 Depth + 1);
452 Depth + 1);
479 computeKnownBitsImpl(SrcReg, Known, DemandedElts, Depth + 1);
499 for (unsigned I = 0; I != NumOps - 1; ++I) {
502 DemandedElts, Depth + 1);
511 Register SrcReg = MI.getOperand(NumOps - 1).getReg();
516 computeKnownBitsImpl(SrcReg, SrcOpKnown, DemandedElts, Depth + 1);
520 for (; DstIdx != NumOps - 1 && MI.getOperand(DstIdx).getReg() != R;
529 computeKnownBitsImpl(SrcReg, Known, DemandedElts, Depth + 1);
535 computeKnownBitsImpl(SrcReg, Known, DemandedElts, Depth + 1);
541 Depth + 1);
554 Depth + 1);
556 Depth + 1);
558 Depth + 1);
565 Depth + 1);
567 Depth + 1);
569 Depth + 1);
603 Depth + 1);
612 LLVM_DEBUG(dumpResult(MI, Known, Depth));
621 unsigned Depth) {
623 unsigned Src1SignBits = computeNumSignBits(Src1, DemandedElts, Depth);
626 return std::min(computeNumSignBits(Src0, DemandedElts, Depth), Src1SignBits);
634 const MDNode *Ranges = Ld->getRanges();
640 switch (Ld->getOpcode()) {
658 unsigned Depth) {
663 return MI.getOperand(1).getCImm()->getValue().getNumSignBits();
665 if (Depth == getMaxDepth())
687 // Don't increment Depth for this one since we didn't do any work.
688 return computeNumSignBits(Src.getReg(), DemandedElts, Depth);
696 unsigned Tmp = DstTy.getScalarSizeInBits() - SrcTy.getScalarSizeInBits();
697 return computeNumSignBits(Src, DemandedElts, Depth + 1) + Tmp;
704 unsigned InRegBits = TyBits - SrcBits + 1;
705 return std::max(computeNumSignBits(Src, DemandedElts, Depth + 1), InRegBits);
717 // FIXME: We need an in-memory type representation.
725 // e.g. i16->i32 = '17' bits known.
727 return TyBits - MMO->getSizeInBits().getValue() + 1;
732 // FIXME: We need an in-memory type representation.
740 // e.g. i16->i32 = '16' bits known.
742 return TyBits - MMO->getSizeInBits().getValue();
749 computeNumSignBits(Src1, DemandedElts, Depth + 1);
753 computeNumSignBits(Src2, DemandedElts, Depth + 1);
765 unsigned NumSrcSignBits = computeNumSignBits(Src, DemandedElts, Depth + 1);
766 if (NumSrcSignBits > (NumSrcBits - DstTyBits))
767 return NumSrcSignBits - (NumSrcBits - DstTyBits);
773 Depth + 1);
785 // If compares returns 0/-1, all bits are sign bits.
786 // We know that we have an integer-based boolean since these operations
805 return TyBits - 1; // Every always-zero bit is a sign bit.
814 TL.computeNumSignBitsForTargetInstr(*this, R, DemandedElts, MRI, Depth);
823 KnownBits Known = getKnownBits(R, DemandedElts, Depth);
836 Mask <<= Mask.getBitWidth() - TyBits;
840 unsigned GISelKnownBits::computeNumSignBits(Register R, unsigned Depth) {
844 return computeNumSignBits(R, DemandedElts, Depth);