From 73a91bcc63694f9431905965632beb638a10e94b Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Wed, 3 Jul 2019 10:59:52 +0000 Subject: [PATCH] [X86][SSE] LowerINSERT_VECTOR_ELT - ensure insertion index correctness. NFCI. Assert that the insertion index is in range and use uint64_t for the index to fix MSVC/cppcheck truncation warning. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365025 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelLowering.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 6050b9217ce..53890af9702 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -17094,7 +17094,8 @@ SDValue X86TargetLowering::LowerINSERT_VECTOR_ELT(SDValue Op, if (!isa(N2)) return SDValue(); auto *N2C = cast(N2); - unsigned IdxVal = N2C->getZExtValue(); + assert(N2C->getAPIntValue().ult(NumElts) && "Out of range element index"); + uint64_t IdxVal = N2C->getZExtValue(); bool IsZeroElt = X86::isZeroNode(N1); bool IsAllOnesElt = VT.isInteger() && llvm::isAllOnesConstant(N1); -- 2.40.0