[llvm] f6524b4 - [PPC] Fix UBSAN warning about out of range shift. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 12 04:03:57 PST 2021


Author: Simon Pilgrim
Date: 2021-03-12T12:03:48Z
New Revision: f6524b4ada823a9766f7cbdfc16e052971e005f6

URL: https://github.com/llvm/llvm-project/commit/f6524b4ada823a9766f7cbdfc16e052971e005f6
DIFF: https://github.com/llvm/llvm-project/commit/f6524b4ada823a9766f7cbdfc16e052971e005f6.diff

LOG: [PPC] Fix UBSAN warning about out of range shift. NFCI.

Added: 
    

Modified: 
    llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
index 45fab4158939..0f6212621ac2 100644
--- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -1043,7 +1043,7 @@ static SDNode *selectI64ImmDirectPrefix(SelectionDAG *CurDAG, const SDLoc &dl,
   unsigned TZ = countTrailingZeros<uint64_t>(Imm);
   unsigned LZ = countLeadingZeros<uint64_t>(Imm);
   unsigned TO = countTrailingOnes<uint64_t>(Imm);
-  unsigned FO = countLeadingOnes<uint64_t>(Imm << LZ);
+  unsigned FO = countLeadingOnes<uint64_t>(LZ == 64 ? 0 : (Imm << LZ));
   unsigned Hi32 = Hi_32(Imm);
   unsigned Lo32 = Lo_32(Imm);
 


        


More information about the llvm-commits mailing list