[llvm] [AMDGPU] Implement hasBitTest to Optimize Bit Testing Operations (PR #112652)
Harrison Hao via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 18 03:56:39 PDT 2024
================
@@ -6043,3 +6043,24 @@ bool AMDGPUTargetLowering::isReassocProfitable(MachineRegisterInfo &MRI,
Register N0, Register N1) const {
return MRI.hasOneNonDBGUse(N0); // FIXME: handle regbanks
}
+
+bool AMDGPUTargetLowering::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;
+
+ auto *ConstantMaskNode = dyn_cast<ConstantSDNode>(Y);
+ if (!ConstantMaskNode)
+ return false;
+
+ APInt MaskValue = ConstantMaskNode->getAPIntValue();
----------------
harrisonGPU wrote:
Okay, I have updated it.
https://github.com/llvm/llvm-project/pull/112652
More information about the llvm-commits
mailing list