This is an archive of the discontinued LLVM Phabricator instance.

[VectorUtils] Attempt to truncate icmps
Needs ReviewPublic

Authored by jmolloy on May 12 2016, 7:15 AM.

Details

Reviewers
hfinkel
Summary

Hi Hal,

This is a toned-down version of r268921, which was reverted due to PR27690.

The intent is the same, which is to allow loops containing icmps to be vectorized at smaller bitwidths. DemandedBits doesn't return any useful information for icmp operands. For example:

%1 = zext i8 %0 to i32
%2 = xor i32 %1, 255
%3 = icmp ult i32 %2, 24

This can obviously become:

%2 = xor i8 %0, 255
%3 = icmp ult i8 %2, 24

But demandedbits will not and can not tell us this, because while the upper 24 bits can be *truncated* and still return the same result, they cannot be arbitrarily changed (undef), which is the criterion DemandedBits uses.

This patch adds a fairly simple version of DemandedBits called DemandedBitsWithAssumptions (bikeshedding accepted). This is a thin wrapper around DemandedBits that allows a user to supply "facts" about the bits demanded in the dataflow graph that perhaps DemandedBits would be unable to deduce itself.

We do need to recompute DemandedBits afresh when doing this; there is possibly room in the future for more caching if this turns out to have an impact.

Diff Detail

Repository
rL LLVM

Event Timeline

jmolloy updated this revision to Diff 57032.May 12 2016, 7:15 AM
jmolloy retitled this revision from to [VectorUtils] Attempt to truncate icmps.
jmolloy updated this object.
jmolloy added a reviewer: hfinkel.
jmolloy set the repository for this revision to rL LLVM.
jmolloy added a subscriber: llvm-commits.
jmolloy updated this revision to Diff 57033.May 12 2016, 7:17 AM