[polly] [InstCombine] Canonicalise SextADD + GEP (PR #69581)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 20 05:56:31 PDT 2023


LiqinWeng wrote:

> It's not at all clear to me that this is a generally profitable transform. Just based on the test changes here, loopflatten.ll is an obvious regression (loop no longer flattened), while induction.ll also looks like a regression to me.
>  
> This is also a regression on the simple instruction count heuristic, as we go from add+sext+gep to 2_sext+2_gep. Possibly what you want to do is limit this to the case where the RHS of the add is a constant, so the sext folds away?

```
void test(int array2[50][50], int a, int b) {
    int loc;
    loc = a + 5;
    array2[loc][loc] += 1;
    array2[loc + 20][loc] = loc;
}
```
For a two-dimensional array, the base address does not need to be recalculated for the second access. It can be obtained through offset.


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


More information about the llvm-commits mailing list