[PATCH] D69514: [InstCombine] Expand usub_sat patterns to handle constants
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 10:10:44 PST 2019
dmgreen updated this revision to Diff 228272.
dmgreen added a comment.
Sorry for the delay. I was trying to look into the "off by one" patterns, the last two of these:
Name: Forwards
Pre: C1 == -C2
%cmp = icmp ugt i8 %a, C1
%sub = add i8 %a, C2
%sel = select i1 %cmp, i8 %sub, i8 0
=>
%sel = usub_sat %a, C1
Name: Backwards
Pre: C1 == -C2
%cmp = icmp ult i8 %a, C1
%sub = add i8 %a, C2
%sel = select i1 %cmp, i8 %sub, i8 0
=>
%x = usub_sat C1, %a
%sel = sub 0, %x
Name: Forwards_off
Pre: C1 + 1 == -C2 && C2 != 0
%cmp = icmp ugt i8 %a, C1
%sub = add i8 %a, C2
%sel = select i1 %cmp, i8 %sub, i8 0
=>
%sel = usub_sat %a, C1 + 1
Name: Backwards_off
Pre: C1 - 1 == -C2 && C1 != 0
%cmp = icmp ult i8 %a, C1
%sub = add i8 %a, C2
%sel = select i1 %cmp, i8 %sub, i8 0
=>
%x = usub_sat C1 - 1, %a
%sel = sub 0, %x
They are a bit fiddly though and deserve to be their own commit.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69514/new/
https://reviews.llvm.org/D69514
Files:
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/builtin-dynamic-object-size.ll
llvm/test/Transforms/InstCombine/unsigned_saturated_sub.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69514.228272.patch
Type: text/x-patch
Size: 4332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191107/f9ae27da/attachment.bin>
More information about the llvm-commits
mailing list