[PATCH] D152430: [DAG] Peek through freeze when deciding whether we should convert setcc to math or not.
Amaury SECHET via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 8 02:26:34 PDT 2023
deadalnix created this revision.
deadalnix added reviewers: n-omer, RKSimon, nikic, MaskRay, goncharov, jplehr, foad.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
deadalnix requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Because later tranform push the freeze through the setcc, we end up having to reconstruct the setcc, which can cause infinite loops.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152430
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -12230,8 +12230,18 @@
// setcc is very commonly used as an argument to brcond. This pattern
// also lend itself to numerous combines and, as a result, it is desired
// we keep the argument to a brcond as a setcc as much as possible.
- bool PreferSetCC =
- N->hasOneUse() && N->use_begin()->getOpcode() == ISD::BRCOND;
+ bool PreferSetCC = [&]() {
+ if (!N->hasOneUse()) {
+ return false;
+ }
+
+ SDNode *U = *N->use_begin();
+ if (U->getOpcode() == ISD::FREEZE && U->hasOneUse()) {
+ U = *U->use_begin();
+ }
+
+ return U->getOpcode() == ISD::BRCOND;
+ }();
ISD::CondCode Cond = cast<CondCodeSDNode>(N->getOperand(2))->get();
EVT VT = N->getValueType(0);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152430.529539.patch
Type: text/x-patch
Size: 932 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230608/65d5585c/attachment.bin>
More information about the llvm-commits
mailing list