https://bugs.llvm.org/show_bug.cgi?id=51783

            Bug ID: 51783
           Summary: Missed arithmetic fold
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

LLVM optimizes bar into tgt here but not foo.

https://godbolt.org/z/jdeT7jbjd

int foo(int a, int b) {
    return b * (1 + a / b) - a;
}
int bar(int a, int b) {
    return b * (a / b) + b - a;
}
int tgt(int a, int b) {
    return b - a % b;
}

https://alive2.llvm.org/ce/z/axgBxW

GCC appears to miss this too.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to