[llvm] [AMDGPU] Elide bitcast fold i64 imm to build_vector (PR #154115)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 16 04:37:42 PDT 2025
================
@@ -5296,6 +5296,36 @@ SDValue AMDGPUTargetLowering::performRcpCombine(SDNode *N,
return DCI.DAG.getConstantFP(One / Val, SDLoc(N), N->getValueType(0));
}
+bool AMDGPUTargetLowering::isInt64ImmLegal(SDNode *N, SelectionDAG &DAG) const {
+ if (!Subtarget->isGCN())
+ return false;
+
+ ConstantSDNode *SDConstant = dyn_cast<ConstantSDNode>(N);
+ ConstantFPSDNode *SDFPConstant = dyn_cast<ConstantFPSDNode>(N);
+ auto &ST = DAG.getSubtarget<GCNSubtarget>();
+ bool isInlineable = false;
+ const auto *TII = ST.getInstrInfo();
+
+ if (!ST.hasMovB64() || (!SDConstant && !SDFPConstant))
+ return false;
+
+ if (ST.has64BitLiterals())
+ return true;
+
+ uint64_t Val = 0;
+ if (SDConstant) {
+ const APInt &APVal = SDConstant->getAPIntValue();
+ isInlineable = TII->isInlineConstant(APVal);
+ Val = APVal.getZExtValue();
----------------
arsenm wrote:
```suggestion
Val = APVal.getZExtValue();
return isUInt<32>(Val) || TII->isInlineConstant(APVal);
```
https://github.com/llvm/llvm-project/pull/154115
More information about the llvm-commits
mailing list