# Loop Fission

DevFeed: [Loop Fission](<https://devfeed.tech/articles/loop-fission-25639.md>)

Original publisher: [Read original article](<https://richardstartin.github.io/posts/loop-fission>)

Author: Richard Startin's Blog

Published: 2021-11-27T00:00:00Z

Content type: tutorial

Language: en

Sources: [Richard Startin's Blog](<https://devfeed.tech/sources/richard-startin-s-blog.md>)

Topics: [Compiler](<https://devfeed.tech/topics/compiler.md>), [JIT](<https://devfeed.tech/topics/jit.md>), [Benchmark](<https://devfeed.tech/topics/benchmark.md>), [Code generation](<https://devfeed.tech/topics/code-generation.md>), [Caching](<https://devfeed.tech/topics/caching.md>), [C++](<https://devfeed.tech/topics/c-plus-plus.md>)

Tags: [benchmark](<https://devfeed.tech/tags/benchmark.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [cache](<https://devfeed.tech/tags/cache.md>), [code-generation](<https://devfeed.tech/tags/code-generation.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [examples](<https://devfeed.tech/tags/examples.md>), [java](<https://devfeed.tech/tags/java.md>), [jit](<https://devfeed.tech/tags/jit.md>), [performance](<https://devfeed.tech/tags/performance.md>)

## AI overview

This article explains loop fission, the practice of splitting a loop that performs multiple tasks into separate loops. Using bitmap XOR and counting examples, it describes how loop fission can improve performance through compiler optimizations such as autovectorization, while noting that fused loops may sometimes benefit from better cache use. It also compares behavior in HotSpot C2 and clang.

## Source excerpt

Loop fission is a process normally applied by a compiler to loops to make them faster. The idea is to split larger loop bodies which perform several distinct tasks into separate loops, in the hope that the individual loops can be optimised more effectively in isolation. As far as I'm aware, C2, Hotspot's JIT compiler, doesn't do this so you have to do it yourself. I came across a couple of cases where this was profitable recently, and this post uses these as examples.