[PATCH] Optimize icmp involving addition better

David Majnemer david.majnemer at gmail.com
Tue Apr 9 21:12:56 PDT 2013


Hello,

The attached patch allows LLVM to optimize sequences like the

%add = add nsw i32 %x, 1
%cmp = icmp sgt i32 %add, %y

into:

%cmp = icmp sge i32 %x, %y

as well as:

%add1 = add nsw i32 %x, 20
%add2 = add nsw i32 %y, 57
%cmp = icmp sge i32 %add1, %add2

into:

%add = add nsw i32 %y, 37
%cmp = icmp sle i32 %cmp, %x

Patches are attached and apply cleanly on r179146

Thanks,
David Majnemer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130409/70d61b5b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: icmp_cst.diff
Type: application/octet-stream
Size: 4216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130409/70d61b5b/attachment.obj>


More information about the llvm-commits mailing list