[llvm-dev] Constrained integer DIV (WAS: Re: Planned change to IR semantics: constant expressions never have undefined behavior)
Cameron McInally via llvm-dev
llvm-dev at lists.llvm.org
Fri Jun 14 16:01:49 PDT 2019
On Fri, Jun 14, 2019 at 6:24 PM Eli Friedman via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> See https://reviews.llvm.org/D63036
> for the full patch and description. Essentially, the Constant::canTrap API
> is going away. To make this work, the semantics of division and remainder
> constant expressions are changing slightly, so division by zero produces
> poison, not undefined behavior. (The corresponding instructions still have
> undefined behavior.) This change should make writing and understanding IR
> optimizations easier.
This is a good change. Thanks for working on it.
I don't mean to steal your thunder, Eli, but I'd like to propose that we
add constrained intrinsics for integer DIV (and maybe REM). Some
architectures, like x86, can trap on integer div-by-zero. I'd like to have
some way to access that behavior, even if the C/C++ Standards say it's
We have a few dusty deck codes in-house that depend on this, so I'm
motivated to push our local changes upstream. That said, if no one else
finds value in this, we can keep it local.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev