[llvm-commits] [PATCH] Add DAGCombine for A-(-B) -> A+B

Chris Lattner clattner at apple.com
Sat Jul 3 21:33:22 PDT 2010


On Jul 3, 2010, at 3:38 PM, Eli Friedman wrote:

> Attached.  I wanted to ask before committing because there might be
> some non-obvious reason we don't already do this transformation...
> 
> This affects IR like the following:
> define i32 @a(i32 %x, i32 %y) nounwind readnone {
> entry:
>  %mul = mul i32 %y, -8
>  %sub = sub i32 %x, %mul
>  ret i32 %sub
> }

Looks fine to me.  It is probably missing because instcombine generally does it.

-Chris





More information about the llvm-commits mailing list