[llvm] [NVPTX] Fix lowering of i1 SETCC (PR #115035)
Alex MacLean via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 19 15:29:28 PST 2024
================
@@ -18754,8 +18754,9 @@ SDValue DAGCombiner::rebuildSetCC(SDValue N) {
if (LegalTypes)
SetCCVT = getSetCCResultType(SetCCVT);
// Replace the uses of XOR with SETCC
- return DAG.getSetCC(SDLoc(N), SetCCVT, Op0, Op1,
- Equal ? ISD::SETEQ : ISD::SETNE);
+ const ISD::CondCode CC = Equal ? ISD::SETEQ : ISD::SETNE;
+ if (!LegalOperations || TLI.isCondCodeLegal(CC, Op0.getSimpleValueType()))
----------------
AlexMaclean wrote:
Yep, we get stuck in an infinite loop: legalization converts the setcc into an xor and then dag combiner converts it back to a setcc over and over again. I've added a comment explaining.
> It appears that we do manage to lower setcc x, y, eq as xor.pred already : https://godbolt.org/z/cMx9d8P33
Good catch, this is the result of some old table-gen patterns which handled `eq` and `ne`. I've removed these as the legalization approach handles these cases and is more powerful since it allows DAGCombiner to manipulate the logical ops created.
https://github.com/llvm/llvm-project/pull/115035
More information about the llvm-commits
mailing list