[PATCH] D145073: [InstCombine] fold signed absolute diff patterns

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 1 08:35:36 PST 2023


spatel created this revision.
spatel added reviewers: goldstein.w.n, RKSimon, dmgreen.
Herald added subscribers: StephenFan, hiraditya, mcrosier.
Herald added a project: All.
spatel requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This overlaps partially with the codegen patch D144789 <https://reviews.llvm.org/D144789>. This needs nsw for correctness, and I'm not sure if there's an unsigned equivalent:
https://alive2.llvm.org/ce/z/ErmQ-9

This is obviously an improvement in IR, and it looks like a codegen win for all targets and data types that I sampled.

The 'nabs' case is not as clean because I think it would require clearing nsw from the subtract to be correct, so that's left as a potential follow-up (and seems less likely to occur in real code).


https://reviews.llvm.org/D145073

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/test/Transforms/InstCombine/abs-1.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145073.501522.patch
Type: text/x-patch
Size: 6758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230301/98ca9f60/attachment.bin>


More information about the llvm-commits mailing list