[PATCH] D49320: [InstCombine] Fold 'check for [no] signed truncation' pattern
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 13 14:06:39 PDT 2018
lebedev.ri created this revision.
lebedev.ri added reviewers: spatel, craig.topper.
Herald added a subscriber: JDevlieghere.
PR38149 <https://bugs.llvm.org/show_bug.cgi?id=38149>
As discussed in https://reviews.llvm.org/D49179#1158957 and later,
the IR for 'check for [no] signed truncation' pattern can be improved:
https://rise4fun.com/Alive/gBf
^ that pattern will be produced by Implicit Integer Truncation sanitizer,
https://reviews.llvm.org/D48958 https://bugs.llvm.org/show_bug.cgi?id=21530
in signed case, therefore it is probably a good idea to improve it.
The DAGCombine will reverse this transform, see
https://reviews.llvm.org/D49266
This transform is surprisingly frustrating.
This does not deal with non-splat shift amounts, or with undef shift amounts.
I've outlined what i think the solution should be:
// Potential handling of non-splats: for each element:
// * if both are undef, replace with constant 0.
// Because (1<<0) is OK and is 1, and ((1<<0)>>1) is also OK and is 0.
// * if both are not undef, and are different, bailout.
// * else, only one is undef, then pick the non-undef one.
Repository:
rL LLVM
https://reviews.llvm.org/D49320
Files:
lib/Transforms/InstCombine/InstCombineCompares.cpp
test/Transforms/InstCombine/canonicalize-lack-of-signed-truncation-check.ll
test/Transforms/InstCombine/canonicalize-signed-truncation-check.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49320.155482.patch
Type: text/x-patch
Size: 7485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180713/bb49755d/attachment-0001.bin>
More information about the llvm-commits
mailing list