Skip to content

[Reassociate?] Optimizing redundant common factor multiplications #155040

@vzakhari

Description

@vzakhari

Is there a pass in LLVM that can optimize this pattern https://godbolt.org/z/hdKsj4nc4?

The expression a*b + a*c + a*b*d may be optimized into a*(b + c + b*d) saving one multiplication.

It looks like ReassociatePass cannot optimize this due to the single-use check for adding the expression into the tree. Is this a hard limitation?

@RKSimon can you please comment?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions