[llvm-commits] Patch: instcombine on overflow intrinsics

Duncan Sands baldrick at free.fr
Mon Nov 9 02:47:58 PST 2009


Hi Alastair,

> This patch adds the follow to instcombine:
>   overflow intrinsic (undef, X) or overflow intrinsic (X, undef) -> undef
>   add overflow (X, 0) or add overflow (0, X) -> {X, false}
>   unsigned add overflow (X, Y) -> {X + Y, true} where the HO bit is 
> provably 1 in both X and Y
>   unsigned add overflow (X, Y) -> {X + Y, false} where the HO bit is 
> provably 0 in both X and Y
>   sub overflow (X, 0) -> {X, false}
>   mul overflow (X, 0) -> {0, false}
>   mul overflow (X, 1) -> {X, false}

how about deleting the overflow intrinsics instead, and add IRBuilder helper
methods for generating "add with overflow" etc that generate the appropriate
apint arithmetic?  That way you should get all these optimizations for free,
and you won't have to redo a huge chunk of integer optimizations.  It may be
that codegen doesn't produce optimal code for the apint versions, but in that
case it's probably best to improve codegen.

Ciao,

Duncan.



More information about the llvm-commits mailing list