[clang] [CIR] Handle proper hoisting of const variables with InvariantGroupOp (PR #175037)

Sirui Mu via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 3 08:18:31 PST 2026


Lancern wrote:

> > Since h is external, LLVM cannot take the risk to eliminate the reload from alloca before calling use, despite that the reload is indeed unnecessary according to the C++ standard
> 
> For the testcase in hand, If cir.alloca was marked as const, wouldn't this allow a LoadOp folder to reuse any existing previous use (if available) instead?

This indeed sounds like a possible way to implement the said "const-propagation" in CIR. Previously, we focused more on teaching LLVM optimizer about our intents, though, so we could get "free" implementations without re-inventing the wheels.

https://github.com/llvm/llvm-project/pull/175037


More information about the cfe-commits mailing list