Issue 131532
Summary SMUL idiom
Labels new issue
Assignees
Reporter DTeachs
    We already turn umul with overflow into the idiom. LLVM should do the same.

I understand this was previously done by @AZero13, but given they now plan to step away from LLVM after everything, I have volunteered to take over this issue in particular.

bool check_multiplication_overflow(int a, int b) {
    // Cast to long long to perform the multiplication
    long long result = (long long)a * (long long)b;

    // Check if the result is within the range of int
    if (result > INT_MAX || result < INT_MIN) {
        return true; // Overflow occurred
    }
    return false; // No overflow
}

This yields the IR targeted.

This code is a modified version of what was found in systemd's source code.


_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to