[llvm] [AMDGPU][SDAG] Legalise v2i32 or/xor/and instructions to make use of 64-bit wide instructions (PR #140694)
Chris Jackson via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 6 05:28:31 PDT 2025
================
@@ -4654,8 +4654,27 @@ AMDGPUTargetLowering::foldFreeOpFromSelect(TargetLowering::DAGCombinerInfo &DCI,
if (!AMDGPUTargetLowering::allUsesHaveSourceMods(N.getNode()))
return SDValue();
- return distributeOpThroughSelect(DCI, LHS.getOpcode(),
- SDLoc(N), Cond, LHS, RHS);
+ // select c, (fneg (f32 bitcast i32 x)), (fneg (f32 bitcast i32 y)) can be
+ // lowered directly to a V_CNDMASK_. So prevent the fneg from being pulled
+ // out in this case. For now I've made the logic as specific to the case as
+ // possible, hopefully this can be relaxed in future.
+ if (LHS.getOpcode() == ISD::FNEG && RHS.getOpcode() == ISD::FNEG) {
+ SDValue LHSB = LHS.getOperand(0);
+ SDValue RHSB = RHS.getOperand(0);
+ if (LHSB.getOpcode() == ISD::BITCAST &&
+ RHSB->getOpcode() == ISD::BITCAST) {
+ EVT LHSBOpTy = LHSB->getOperand(0).getValueType();
+ EVT RHSBOpTy = RHSB->getOperand(0).getValueType();
+ if (LHSB.getValueType() == MVT::f32 &&
+ RHSB.getValueType() == MVT::f32 && LHSBOpTy == MVT::i32 &&
+ RHSBOpTy == MVT::i32) {
+ return SDValue();
+ }
+ }
+ }
+
+ return distributeOpThroughSelect(DCI, LHS.getOpcode(), SDLoc(N), Cond, LHS,
+ RHS);
----------------
chrisjbris wrote:
Just double-checked. Yes, the work of clang-format.
https://github.com/llvm/llvm-project/pull/140694
More information about the llvm-commits
mailing list