[LLVMdev] Integer divide by zero

Cameron McInally cameron.mcinally at nyu.edu
Mon Apr 8 09:01:48 PDT 2013


Hey Duncan,

On Mon, Apr 8, 2013 at 3:39 AM, Duncan Sands <baldrick at free.fr> wrote:
...

> I reckon it shouldn't be too hard to teach the code generators to turn
> this IR
> sequence into "y = target-divide whatever/x" on targets for which dividing
> by 0
> traps in a satisfactory way, so it turns into something efficient.
>

I was just writing Chandler about a similar implementation. With my current
understanding of the problem, my constant division will end up as either a
trap call or a load of an undefined value in the IR, depending on what the
FE chooses to do. It's not clear to me, at least with my current knowledge
of LLVM, how to recreate the actual division instruction in the target
backend from that information (trap or undefined value). Hopefully there is
a way. ;)

Thanks again, Duncan.

-Cameron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130408/f0a190d8/attachment.html>


More information about the llvm-dev mailing list