[PATCH] D129396: [InstCombine] Add support for div, ldiv, lldiv, and imaxdiv folding

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 8 13:38:08 PDT 2022


nikic added a comment.

> I would have wanted to implement (1) in the initial patch, mostly as a learning exercise, but couldn't find a simple way to create an initializer for a nonconstant struct like there is for a constant one with ConstantStruct::get(). Any suggestions?

The general pattern for this is to start with a `PoisonValue` and then use a chain of  `CreateInsertValue` to insert values into the struct. https://github.com/llvm/llvm-project/blob/adf1ffe95854a245cbc48bbaea55f60b003d5f76/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp#L794 is very similar to your case (this one creates and `{poison, 0}` struct and then `insertvalue`s into the first value).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129396/new/

https://reviews.llvm.org/D129396



More information about the llvm-commits mailing list