[llvm] Improve selection of conditional branch on amdgcn.ballot!=0 condition in SelectionDAG. (PR #68714)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 11 03:15:36 PDT 2023
================
@@ -13584,6 +13585,56 @@ SDValue SITargetLowering::performClampCombine(SDNode *N,
return SDValue(CSrc, 0);
}
+SDValue SITargetLowering::performBRCondCombine(SDNode *N,
+ DAGCombinerInfo &DCI) const {
+ if (!DCI.isAfterLegalizeDAG())
+ return SDValue(N, 0);
+
+ SDValue Cond = N->getOperand(1);
+ if (Cond.getOpcode() == ISD::SETCC &&
+ Cond->getOperand(0)->getOpcode() == AMDGPUISD::SETCC) {
+
+ // %VCMP = i32/i64 AMDGPUISD::SETCC ...
+ // %C = ISD::SETCC %VCMP, 0, setne/seteq
+ // BRCOND %BB, %C
+ // =>
+ // %VCMP = i32/i64 AMDGPUISD::SETCC ...
+ // BRCONDZ %BB, %VCMP, setne/seteq
----------------
jayfoad wrote:
Why does `VCMP` have to be `AMDGPUISD::SETCC` here? Can you do a simpler combine instead:
```
// %C = ISD::SETCC %VCMP, 0, setne/seteq
// BRCOND %BB, %C
// =>
// BRCONDZ %BB, %VCMP, setne/seteq
```
https://github.com/llvm/llvm-project/pull/68714
More information about the llvm-commits
mailing list