p4c icon indicating copy to clipboard operation
p4c copied to clipboard

common subexpression elimination

Open Mohxen opened this issue 3 years ago • 2 comments

Hi all,

I check the name and the code of passes in the frontend and midend. I found some passes which eliminate different structures, especially the passes whose names start with "eliminate" but I am not sure they do common subexpression elimination. Please let me know in which passes you used it (CSE).

Mohxen avatar Dec 08 '22 02:12 Mohxen

The compiler doesn't do cse

mihaibudiu avatar Dec 08 '22 02:12 mihaibudiu

There is a pass called "LocalCopyPropagation" that I would in some cases call "common subexpression proliferation", since it can cause common subexpressions to be repeated many times in the code. :-)

See https://github.com/p4lang/p4c/issues/2316 for an example kind of program that can lead to that behavior. Most programs in practice do not have such an effect.

jfingerh avatar Dec 08 '22 05:12 jfingerh

There is a pass called "LocalCopyPropagation" that I would in some cases call "common subexpression proliferation", since it can cause common subexpressions to be repeated many times in the code. :-)

See #2316 for an example kind of program that can lead to that behavior. Most programs in practice do not have such an effect. Thank you, let me know compiler still has a problem with LocalCopyPropagation you mentioned in #2316.

Mohxen avatar Dec 12 '22 19:12 Mohxen

Mohxen wrote: "Thank you, let me know compiler still has a problem with LocalCopyPropagation you mentioned in https://github.com/p4lang/p4c/issues/2316."

As far as I know, yes. The issue is still open, with no PR claiming to address it. The test program named proliferation1.p4.txt (https://github.com/p4lang/p4c/files/4478275/proliferation1.p4.txt) that is attached to the first comment of that issue can easily be tried for compilation using p4c built from the latest version of the p4c source code, to confirm.

jfingerh avatar Dec 12 '22 20:12 jfingerh