[PATCH][X86] Lower unsigned vsetcc to psubus in certain cases

Quentin Colombet qcolombet at apple.com
Tue Feb 25 17:07:37 PST 2014


Hi Adam,

This LGTM with two comments:

1. Could you add a comment on why this is not useful for AVX?
 +      if (Subtarget->hasAVX())
 +        break;

2. As it is your CHECK-LABEL lines may cause failure on pecoff target, see r201931 on how to fix that.

Thanks,
-Quentin

On Feb 24, 2014, at 2:36 PM, Adam Nemet <anemet at apple.com> wrote:

> This is another improvement for SingleSource/Benchmarks/Misc/lowercase.c.
> 
> The current approach to lower a vsetult is to flip the sign bit of the operands, swap the operands and then use a (signed) pcmpgt.  psubus (unsigned saturating subtract) can be used to emulate a vsetult more efficiently:
> 
> +    case ISD::SETULT: {
> +      // If the comparison is against a constant we can turn this into a
> +      // setule.  With psubus, setule does not require a swap.  This is
> +      // beneficial because the constant in the register is no longer
> +      // destructed as the destination so it can be hoisted out of a loop.
> 
> I also enable lowering via psubus in a few other cases where it’s clearly beneficial: setule and setuge if minu/maxu cannot be used.  You can see the improvements in the diff to the existing test vec_setcc.ll.
> 
> I am leaving the other case alone for now because it’s harder to reason about profitability in those cases.
> 
> Tested on x86_64-apple-darwin.
> 
> Please apply if it looks good.
> 
> Adam
> 
> <rdar://problem/14338765>
> 
> <vsetcc-psubus-v1.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140225/1c60da8a/attachment.html>


More information about the llvm-commits mailing list