Issue 108910
Summary Loop gets vectorized when it can be folded to a constant
Labels new issue
Assignees
Reporter dcci
    ```
#include <stdint.h>

int64_t foo() {
    int64_t result = 0;
    for (int r = 0; r < 7; r++) {
 for (int s = 0; s < 10; s++) {
            for (int t = 0; t < 10; t++) {
                if (t + s + r == 10) {
                    result += 1;
                }
            }
        }
    }
    return result;
}
```

https://clang.godbolt.org/z/vfWGc1MWK

Changing the condition from `t + s + r` into `t + s` results in LLVM optimizing the code to just:

```
foo:
        mov     eax, 63
 ret
```

cc: @fhahn 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to