[llvm] [AMDGPU] Implement hasBitTest to Optimize Bit Testing Operations (PR #112652)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 19 06:04:22 PDT 2024
================
@@ -16890,3 +16890,28 @@ SITargetLowering::lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *AI) const {
AI->eraseFromParent();
return LI;
}
+
+bool SITargetLowering::hasBitTest(SDValue X, SDValue Y) const {
+ if (X->isDivergent() || Y->isDivergent())
+ return false;
+
+ EVT VT = X.getValueType();
+
+ if (VT != MVT::i32 && VT != MVT::i64)
+ return false;
+
+ if (VT.isVector()) {
+ EVT ScalarType = VT.getScalarType();
+ if (ScalarType != MVT::i32 && ScalarType != MVT::i64)
+ return false;
+ }
+
+ auto *IsConstOrIsConstSplat = dyn_cast<ConstantSDNode>(Y);
+ if (!dyn_cast<ConstantSDNode>(Y))
----------------
arsenm wrote:
This is the same thing twice. This is also lying, it won't cover splat. You want the helper function isConstOrConstSplat
https://github.com/llvm/llvm-project/pull/112652
More information about the llvm-commits
mailing list