Skip to content

[InstCombine] (m+m)/(m) is not optimized when m=a+a+a, but it is for m=a+a #72114

@ZY546

Description

@ZY546

https://godbolt.org/z/Y84oh497E

int m, n;
void func(int a){

    m=a+a+a;
    n=(m+m)/(m);
}

We note that the expression (m+m)/m is optimized to 2 if the number of a in the expression assigned to m is 2ⁿ, otherwise it is not optimized.

proof:
https://alive2.llvm.org/ce/z/y9amEc

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions