[llvm] [SelectionDAG] Make `(a & x) | (~a & y) -> (a & (x ^ y)) ^ y` available for all targets (PR #137641)

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 29 01:46:31 PDT 2025


================
@@ -1296,6 +1296,11 @@ bool SystemZTargetLowering::allowsMisalignedMemoryAccesses(
   return true;
 }
 
+bool SystemZTargetLowering::hasAndNot(SDValue Y) const {
+  // requires VNC instruction
+  return Subtarget.hasVector() && Y.getValueType().getScalarSizeInBits() <= 128;
----------------
uweigand wrote:

This isn't quite correct, it should be something like
```
bool SystemZTargetLowering::hasAndNot(SDValue Y) const {
  EVT VT = Y.getValueType();

  // We can use NC(G)RK for types in GPRs ...  
  if (VT == MVT::i32 || VT == MVT::i64)
    return Subtarget.hasMiscellaneousExtensions3();

  // ... or VNCs for types in VRs.
  if (VT.isVector() || VT == MVT::i128)
    return Subtarget.hasVector();
}
```

Not sure if we need to restrict to vector integer types, or if that's already done by common code.

https://github.com/llvm/llvm-project/pull/137641


More information about the llvm-commits mailing list