[PATCH] D42951: [CGP] Strength reduce cmp (xor (a, -1), xor(b, -1)) => cmp (b, a)
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 01:38:01 PST 2018
dmgreen created this revision.
dmgreen added reviewers: samparker, john.brawn, spatel.
Herald added a subscriber: javed.absar.
This is (hopefully) the last part of PR35875. The code sequence we currently have
is slightly worse than the original form, due to a higher register pressure causing
more spills on thumb1 cores with few registers.
The sequence:
%an = xor i8 %a, -1
%bn = xor i8 %b, -1
%cmp15 = icmp ult i8 %an, %bn
%cond = select i1 %cmp15, i8 %an, i8 %bn
is strength-reduced to
%an = xor i8 %a, -1
%bn = xor i8 %b, -1
%cmp15 = icmp ult i8 %b, %a
%cond = select i1 %cmp15, i8 %an, i8 %bn
I originally tried to do this during ISEL optimisation, but constant-hoist has
transformed the -1 to constants and pulled them out into higher blocks. So it
would need to look through truncate/zext/register chains into different basic
blocks. Instead it is done here in codegen prepare, late in the pipeline so as to
not break the representation of min/max.
https://reviews.llvm.org/D42951
Files:
lib/CodeGen/CodeGenPrepare.cpp
test/Transforms/CodeGenPrepare/ARM/xorcmp.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42951.132955.patch
Type: text/x-patch
Size: 11614 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180206/b7689be9/attachment.bin>
More information about the llvm-commits
mailing list