[PATCH] D142602: [X86] Expand transform (icmp eq/ne (ABS A), C) -> (and/or (icmp eq/ne A, C), (icmp eq/ne A, -C))

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 12 03:36:01 PST 2023


RKSimon added inline comments.


================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:53461
+          ConvertToLogicOpOfSETCC =
+              CInt.isPowerOf2() && !CInt.isMinSignedValue();
+        }
----------------
goldstein.w.n wrote:
> RKSimon wrote:
> > goldstein.w.n wrote:
> > > RKSimon wrote:
> > > > Doesn't this need to apply to the vector cases as well?
> > > > Doesn't this need to apply to the vector cases as well?
> > > 
> > > No, for the scalar case we have a little hack to handle `(X == Pow2C || X == -Pow2C)` which is the only case this is really worth it.
> > > 
> > > For the vector case if there is no fast `abs` its preferable for an arbitrary `C` to do `X == C || X == -C` as opposed to `Abs(X) == Abs(C)`.
> > In which case, could we move the isConstOrConstSplat check inside the isScalarInteger test and replace the -CInt with getNode() / FoldConstantArithmetic() ?
> What do you mean by this? As in don't go through APInt to get the value of C/-C? Is there an issue how with it is now?
As it is now it will only work for RHS with uniform/splat values - but there doesn't appear to be any reason for the vector case not to work for non-uniform cases


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142602/new/

https://reviews.llvm.org/D142602



More information about the llvm-commits mailing list