Passing a 64-bit result of a call like Value::getZExtValue() as an argument to StringRef::substr() in a 32-bit build truncates the value and, in the two test cases in bug 54739, leads to incorrect folding. The attached change adjusts the calls to StringRef::substr() to avoid the truncation in these two instances.
I considered changing StringRef::substr() to use uint64_t but since the use of size_t in the StringRef API is pervasive and due to its interplay with StringRef::npos and sometimes std::string::npos and the potential for unintended semantic changes, decided against it. I reviewed the rest of SimplifyLibCalls.cpp for similar problems and didn't spot any, but I suspect there may be others in the rest of the code base.
Tested on x86_64-linux in ILP32 and LP64 modes. (The ILP32 test run shows a few crashes that appear unrelated to this change.)
This comment is redundant with the function comment now.