[PowerPC][NFC] Added assertion of shift exponent is too large for 'uint64_t'.
authorEsme-Yi <esme.yi@ibm.com>
Mon, 21 Dec 2020 06:16:50 +0000 (06:16 +0000)
committerEsme-Yi <esme.yi@ibm.com>
Mon, 21 Dec 2020 06:16:50 +0000 (06:16 +0000)
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp

index cd609af0ffe6a2ae60d6d02e45b41d74481196e6..4ecadfbb1b8a6f30062cd7865dbcc9262777f377 100644 (file)
@@ -816,8 +816,6 @@ static SDNode *selectI64ImmDirect(SelectionDAG *CurDAG, const SDLoc &dl,
   unsigned LZ = countLeadingZeros<uint64_t>(Imm);
   unsigned TO = countTrailingOnes<uint64_t>(Imm);
   unsigned LO = countLeadingOnes<uint64_t>(Imm);
-  // Count of ones follwing the leading zeros.
-  unsigned FO = countLeadingOnes<uint64_t>(Imm << LZ);
   unsigned Hi32 = Hi_32(Imm);
   unsigned Lo32 = Lo_32(Imm);
   SDNode *Result = nullptr;
@@ -843,6 +841,9 @@ static SDNode *selectI64ImmDirect(SelectionDAG *CurDAG, const SDLoc &dl,
 
   // Following patterns use 2 instructions to materialize the Imm.
   InstCnt = 2;
+  assert(LZ < 64 && "Unexpected leading zeros here.");
+  // Count of ones follwing the leading zeros.
+  unsigned FO = countLeadingOnes<uint64_t>(Imm << LZ);
   // 2-1) Patterns : {zeros}{31-bit value}
   //                 {ones}{31-bit value}
   if (isInt<32>(Imm)) {