Issue 78891
Summary `a + b - abs(a - b)` --> `2 * MIN(a, b)`, and `a + b + abs(a - b)` --> `2 * MAX(a, b)`
Labels new issue
Assignees
Reporter k-arrows
    Alive2 Proof: https://alive2.llvm.org/ce/z/6Es_iH
Godbolt: https://godbolt.org/z/W7GGKd3jo
```c
#include <stdlib.h>

#define MIN(i, j) (((i) < (j)) ? (i) : (j))
#define MAX(i, j) (((i) > (j)) ? (i) : (j))

int src1(int a, int b)
{
    return a + b - abs(a - b);
}

int tgt1(int a, int b)
{
    return 2 * MIN(a, b);
}

int src2(int a, int b)
{
    return a + b + abs(a - b);
}

int tgt2(int a, int b)
{
    return 2 * MAX(a, b);
}
```

At least from my point of view, no real-world motivation exists here. So this issue may be more of a theoretical confirmation than a benefit to this simplification. 
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to