Loop idiom recognition
The compiler pass that spots a hand-written loop doing something a library or a single instruction already does, and replaces it with memset, memcpy or that instruction.
A loop that zeroes an array byte by byte is slower than libc's hand-tuned memset with its wide vector stores. LLVM's LoopIdiomRecognize pass and GCC's -ftree-loop-distribute-patterns look for such patterns and swap in calls. The same machinery recognizes bit-twiddling loops that count set bits and turns them into popcnt when the target has it.
The classic trap catches people writing libc. Implement memset in C with a plain loop and the compiler recognizes the idiom and replaces the loop body with a call to — memset. The result is infinite recursion, and the reason C libraries get built with -fno-builtin or -ffreestanding.