[llvm] [DAG] Fold build_vector(build_pair()) patterns. (PR #88261)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 13 21:37:43 PDT 2024


topperc wrote:

Aren't build_pair usually created for illegal types either during argument lowering or type legalization. Wouldn't they normally be removed by the type legalizer?

For the mmx case, I see this in initial SelectionDAG

```
      t7: i32,ch = load<(load (s32) from %fixed-stack.1)> t0, FrameIndex:i32<-3>, undef:i32
      t9: i32,ch = load<(load (s32) from %fixed-stack.0)> t0, FrameIndex:i32<-4>, undef:i32
    t12: i64 = build_pair t7, t9
  t13: v1i64 = BUILD_VECTOR t12
```

Previously the build_pair plus 2 loads were combined into a single i64 load.

After the first DAG combine we end up with
```
          t34: i64,ch = load<(load (s64) from %fixed-stack.1, align 4)> t0, FrameIndex:i32<-3>, undef:i32
        t13: v1i64 = BUILD_VECTOR t34
```

Does this patch prevent the build_pair+load combine because the build_pair gets absorbed early?

What would we get if we combined a single element build_vector+load into a load of the vector type?

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


More information about the llvm-commits mailing list