[LLVMdev] Checked arithmetic
Jonathan S. Shapiro
shap at eros-os.com
Wed Mar 26 14:14:02 PDT 2008
On Wed, 2008-03-26 at 21:55 +0100, Duncan Sands wrote:
> Hi Chris,
> > > what's the point? We have this today with apint codegen (if you turn on
> > > LegalizeTypes). For example, this function
> > The desired code is something like:
> > foo:
> > addl %eax, %ecx
> > jo overflow_happened
> > use(%ecx)
> ...is there any chance
> of codegen being capable one day of combining carry arithmetic coming
> from apint and the appropriate conditional branch into a "jo"?
This particular use case pattern (cond branch using CC value generated
as a side effect of a useful operation) appears often enough to be worth
So if it's beyond what codegen can do, then codegen wants to be fixed.
It's clear enough that I can get working code emitted today -- that's
not the issue. The concern is that languages supporting non-hardware
arithmetic precisions rely on this particular pattern a whole lot.
I definitely need to dig in harder and understand how LLVM works before
I try to seriously advocate anything on this topic (or any other), but
from a surface understanding of the IR, and experience building several
prior compilers, I would say that the current IR is very well suited to
C and not yet an ideal match to Ada, COBOL, or some other languages.
That's not a criticism. Just a statement of first impressions.
More information about the llvm-dev