Agree that the code is wrong, and the vectorizer appears to be out of line. Out of curiosity, does anything change if the "const" is taken off of const char* source? It shouldn't make a difference without __restrict__, but I'm grasping at straws for why the vectorizer thinks source and target can be dealiased. In any case there shouldn't be anything target-specific about this bug, so opening a GCC tree-optimization bug is called for... If you toss me a reduced test case I can also take a look at the vect-details dump to narrow it down a bit, but there have been a lot of changes to the vectorizer since I last poked my nose in there. (-fvect-cost-model=dynamic didn't even exist, so I don't know what that is.)
Agree that the code is wrong, and the vectorizer appears to be out of line. Out of curiosity, does anything change if the "const" is taken off of const char* source? It shouldn't make a difference without __restrict__, but I'm grasping at straws for why the vectorizer thinks source and target can be dealiased. In any case there shouldn't be anything target-specific about this bug, so opening a GCC tree-optimization bug is called for... If you toss me a reduced test case I can also take a look at the vect-details dump to narrow it down a bit, but there have been a lot of changes to the vectorizer since I last poked my nose in there. (-fvect- cost-model= dynamic didn't even exist, so I don't know what that is.)