Metal: Allow optimization of simple loops Reimplement the feature to avoid undefined behavior of infinite loops. Add EnsureLoopForwardProgress rewrite pass that inserts a volatile variable access to all loops that it cannot analyze as being finite. Detect loops of form `for (; i <op> x; ++i)` as being finite. The <op> can be any of <,<=,>,>=,==, != operator. The i can be int or uint. The ++i can be -- or ++, -=1, +=1. This assumes that backends using the feature emit signed int arithmetic with defined wraparound semantics. Uses volatile write instead of asm("") due to asm not forcing the behavior in some compiler versions. The volatile variable access is defined in C++ as forward progress, and by inheritance this works in MSL. Later commits may remove injectAsmStatementIntoLoopBodies if ensureLoopForwardProgress is appropriate for all use-cases. Bug: angleproject:418918522 Change-Id: Ic9c29f57044b792195386483208632354d24c854 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6575051 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>