Some forms of vectorisation compiler passes (e.g., a polyhedral analysis) can detect such patterns statically. But, so far, they only work reliably in cases where it is equally easy to offload the processing to a GPU manually.