[PATCH] D12703: [InstCombine] Optimize icmp slt signum(x), 1 --> icmp sle x, 0.
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 13:33:36 PDT 2015
sanjoy created this revision.
sanjoy added a reviewer: majnemer.
sanjoy added a subscriber: llvm-commits.
`signum(x)` is sometimes implemented as `(x >> 63) | (-x >>> 63)` (for
an `i64` `x`). This change adds a pattern matcher for that pattern, and
adds an instcombine rule to optimize `signum(x) s< 1`.
Later, we can also consider optimizing:
icmp slt signum(x), 0 --> icmp slt x, 0
icmp sle signum(x), 1 --> true
etc.
http://reviews.llvm.org/D12703
Files:
include/llvm/IR/PatternMatch.h
lib/Transforms/InstCombine/InstCombineCompares.cpp
test/Transforms/InstCombine/compare-signs.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12703.34245.patch
Type: text/x-patch
Size: 4277 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150908/72be1026/attachment.bin>
More information about the llvm-commits
mailing list