llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.87k stars 11.93k forks source link

predictive commoning: reduce load instructions #95761

Open vfdff opened 4 months ago

vfdff commented 4 months ago
vfdff commented 4 months ago

some smarter case, https://gcc.godbolt.org/z/Ej9Ker6v1

pinskia commented 4 months ago

Note the improvement for GCC comes from GCC's Predictive commoning pass which can be read up about via IBM's slides from 2004 on their XLC compiler implementation: http://www.cs.ualberta.ca/~amaral/cascon/CDP04/slides/tal.pdf.

https://lists.llvm.org/pipermail/llvm-dev/2012-December/056550.html was the last reference I saw mentioned for LLVM.

sjoerdmeijer commented 2 months ago

I have removed the "[AArch64]" tag as I don't think this is target specific.

The first test case testsuite/gcc.dg/tree-ssa/predcom-1.c from GCC's test suite nicely illustrates the missed opportunity with a simple fibonacci example:

https://godbolt.org/z/zTf9YMzbo

There is another example of dead store elimination in testsuite/gcc.dg/tree-ssa/predcom-dse-1.c:

https://godbolt.org/z/83rWKsvYc

madhur13490 commented 1 month ago

Is anyone (except @sjoerdmeijer) planning to work on this?