[llvm] [GlobalISel] Handle div-by-pow2 (PR #83155)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 08:31:02 PST 2024
shiltian wrote:
> > After taking the advices, the code generated from GlobalISel was not changed for the case above. Need to figure out where they come from, especially the compare instruction.
>
> You are still generating too much instructions. For example,
>
> ```
> auto C1 = Builder.buildCTTZ(Ty, RHS);
> ```
>
> `RHS` is a constant, and you have the value in `RHSC`. So instead of generating a `G_CTTZ` instruction, take the constant value (`APInt Cst = RHSC->Value;`), calculate the result, and use the resulting constant in the next step. Same with the `G_SUB` for the inexact value.
This does it. Thanks! It looks like there is no sort of "constant folding" after this pass.
https://github.com/llvm/llvm-project/pull/83155
More information about the llvm-commits
mailing list