[llvm] [AMDGPU] Implement hasAndNot for scalar bitwise AND-NOT operations. (PR #112647)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed May 21 02:57:13 PDT 2025


================
@@ -17577,3 +17577,13 @@ SITargetLowering::lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *AI) const {
   AI->eraseFromParent();
   return LI;
 }
+
+bool SITargetLowering::hasAndNot(SDValue Op) const {
+  // AND-NOT is only valid on uniform (SGPR) values; divergent values live in
+  // VGPRs.
+  if (Op->isDivergent())
+    return false;
+
+  EVT VT = Op.getValueType();
+  return VT == MVT::i32 || VT == MVT::i64;
----------------
jayfoad wrote:

I'm not sure we need to check types here. How about just `return !Op->isDivergent();`? If the types are not legal they will get legalized, but that should not affect the decision of whether to form an and-not pattern.

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


More information about the llvm-commits mailing list