From d6aa0ec737785d9b14f9dd9bb6d101892155f8c2 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 21 Mar 2015 22:04:26 +0000 Subject: [SimplifyLibCalls] Fix negative shifts being produced by the memchr -> bitfield transform. llvm-svn: 232903 --- llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index f6cc431656b..5867d65e7e4 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -782,7 +782,9 @@ Value *LibCallSimplifier::optimizeMemChr(CallInst *CI, IRBuilder<> &B) { // memchr("\r\n", C, 2) != nullptr -> (C & ((1 << '\r') | (1 << '\n'))) != 0 // after bounds check. if (!CharC && !Str.empty() && isOnlyUsedInZeroEqualityComparison(CI)) { - unsigned char Max = *std::max_element(Str.begin(), Str.end()); + unsigned char Max = + *std::max_element(reinterpret_cast(Str.begin()), + reinterpret_cast(Str.end())); // Make sure the bit field we're about to create fits in a register on the // target. -- cgit v1.2.3