[PATCH] D51929: [DAGCombiner] use UADDO to optimize saturated unsigned add

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 11 07:03:04 PDT 2018


spatel created this revision.
spatel added reviewers: craig.topper, lebedev.ri, efriedma, t.p.northover.
Herald added subscribers: kristof.beyls, mcrosier.
Herald added a reviewer: javed.absar.

This is a preliminary step towards solving PR14613:
https://bugs.llvm.org/show_bug.cgi?id=14613

If we have an 'add' instruction that sets flags, we can use that to eliminate an explicit compare instruction or some other instruction (cmn) that sets flags for use in the later select.

As shown in the unchanged tests that use 'icmp ugt %x, %a', we're effectively reversing an IR icmp canonicalization that replaces a variable operand with a constant:
https://rise4fun.com/Alive/V1Q

But we're not using 'uaddo' in those cases via DAG transforms. This happens in CGP after https://reviews.llvm.org/D8889 without checking target lowering to see if the op is supported. That's why AArch64 only shows diffs for i32/i64. The existing codegen for the CGP-altered i8/i16 tests suggests that AArch could do better by marking the other types as 'custom', but that's outside the scope of this patch.


https://reviews.llvm.org/D51929

Files:
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  test/CodeGen/AArch64/sat-add.ll
  test/CodeGen/X86/sat-add.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51929.164859.patch
Type: text/x-patch
Size: 6006 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180911/af7c910a/attachment.bin>


More information about the llvm-commits mailing list