The memchr and memcmp folders fail for the results of pointer addition involving fractional offsets into constants of types other than i8, such as in
const int a[] = { 0x01010101, 0x02020202 }; void* f (void) { return memchr((const char*)a + 1, 1, 7); }
and similar examples involving structs and unions. This is due to what seems like an overly restrictive check in the getConstantDataArrayInfo that keeps the function from "looking through [all] bitcast instructions and geps" despite the comment documenting this intent.
In conjunction with the recent enhancement to let all libcall folders work with subobjects of constants of arbitrary types (D125114), this change removes the limitation above, bringing the memchr and memcmp folders up to par with GCC. Tested on by running make check-all on x86_64-linux.
(The code in getConstantDataArrayInfo could stand to be simplified by letting the function take a DataLayout argument. I stopped short of making that change in this patch to minimize the extent of the changes.)
You can move this out of the GEPOperator block and also drop the stripPointerCasts() above (and the repeated checks of GV below it). All cases can be treated uniformly.