[PATCH] D101232: [InstCombine] Fold comparison of integers by parts
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 24 07:48:12 PDT 2021
nikic created this revision.
nikic added reviewers: spatel, lebedev.ri, xbolva00.
Herald added a subscriber: hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Let's say you represent `(i32, i32)` as an `i64` from which the parts are extracted with lshr/trunc. Then, if you compare two tuples by parts you get something like `A[0] == B[0] && A[1] == B[1]`, just that the part extraction happens by lshr/trunc and not a narrow load or similar.
The fold implemented here reduces such equality comparisons by converting them into a comparison on a larger part of the integer (which might be the whole integer).
This handles the and+eq case, but or+ne could be handled analogously. I'm also being conservative with one-use for now, though this could be relaxed if profitable (the base pattern converts 11 instructions into 5 instructions, but there's quite a few variations on how it can play out).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D101232
Files:
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/eq-of-parts.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101232.340278.patch
Type: text/x-patch
Size: 14827 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210424/caff781c/attachment-0001.bin>
More information about the llvm-commits
mailing list