Skip to content

Simplification for (-a * b) / (a * b) and (-a + b) / (a - b) #69574

Closed
@k-arrows

Description

@k-arrows

The following two functions can be evaluated as true.

bool f(int a, int b)
{
   return (-a * b) / (a * b);
}

bool g(int a, int b)
{
   return (-a + b) / (a - b);
}

https://godbolt.org/z/sa5nTd9ob
https://alive2.llvm.org/ce/z/c5EBFp

GCC and MSVC can simplify the function f.

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