From: Simon Pilgrim Date: Wed, 8 May 2019 11:22:10 +0000 (+0000) Subject: [LegalizeDAG] Assert non-power-of-2 load/store op splits are in range. NFCI. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c30385fc1864606dfb785d8fb37f27371020cf6;p=llvm [LegalizeDAG] Assert non-power-of-2 load/store op splits are in range. NFCI. Fixes static analyzer undefined/out-of-range shift warnings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360245 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 3c362177ce4..f5a1a8cd084 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -539,7 +539,9 @@ void SelectionDAGLegalize::LegalizeStoreOps(SDNode *Node) { } else if (StWidth & (StWidth - 1)) { // If not storing a power-of-2 number of bits, expand as two stores. assert(!StVT.isVector() && "Unsupported truncstore!"); - unsigned RoundWidth = 1 << Log2_32(StWidth); + unsigned LogStWidth = Log2_32(StWidth); + assert(LogStWidth < 32); + unsigned RoundWidth = 1 << LogStWidth; assert(RoundWidth < StWidth); unsigned ExtraWidth = StWidth - RoundWidth; assert(ExtraWidth < RoundWidth); @@ -753,7 +755,9 @@ void SelectionDAGLegalize::LegalizeLoadOps(SDNode *Node) { } else if (SrcWidth & (SrcWidth - 1)) { // If not loading a power-of-2 number of bits, expand as two loads. assert(!SrcVT.isVector() && "Unsupported extload!"); - unsigned RoundWidth = 1 << Log2_32(SrcWidth); + unsigned LogSrcWidth = Log2_32(SrcWidth); + assert(LogSrcWidth < 32); + unsigned RoundWidth = 1 << LogSrcWidth; assert(RoundWidth < SrcWidth); unsigned ExtraWidth = SrcWidth - RoundWidth; assert(ExtraWidth < RoundWidth);