[llvm] [GlobalISel] Handle div-by-pow2 (PR #83155)

Kai Nacke via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 07:40:34 PST 2024


redstar 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.

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


More information about the llvm-commits mailing list