[llvm] [AMDGPU] Fold fneg into select source modifiers (PR #201426)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 9 02:55:27 PDT 2026
================
@@ -5070,13 +5070,19 @@ AMDGPUTargetLowering::foldFreeOpFromSelect(TargetLowering::DAGCombinerInfo &DCI,
SDValue RHS = N.getOperand(2);
EVT VT = N.getValueType();
- if ((LHS.getOpcode() == ISD::FABS && RHS.getOpcode() == ISD::FABS) ||
- (LHS.getOpcode() == ISD::FNEG && RHS.getOpcode() == ISD::FNEG)) {
+ if (LHS.getOpcode() == ISD::FNEG && RHS.getOpcode() == ISD::FNEG) {
+ if (shouldFoldFNegIntoSrc(N.getNode(), SDValue()) &&
+ shouldFoldFNegIntoSelect(N, LHS.getOperand(0), RHS.getOperand(0)))
+ return SDValue();
+
+ return distributeOpThroughSelect(DCI, ISD::FNEG, SDLoc(N), Cond, LHS, RHS);
+ }
+
+ if (LHS.getOpcode() == ISD::FABS && RHS.getOpcode() == ISD::FABS) {
----------------
arsenm wrote:
The same probably applies to fabs, but best to look into that separately
https://github.com/llvm/llvm-project/pull/201426
More information about the llvm-commits
mailing list