[PATCH] D57921: [DAG] Cleanup unused node in SimplifySelectCC.
Nirav Dave via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 7 13:12:48 PST 2019
niravd created this revision.
niravd added reviewers: spatel, RKSimon, craig.topper.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
Delete temporarily constructed node uses for analysis after it's use,
holding onto original input nodes. Ideally this would be rewritten
without making nodes, but this appears relatively complex.
Repository:
rL LLVM
https://reviews.llvm.org/D57921
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/xor.ll
Index: llvm/test/CodeGen/X86/xor.ll
===================================================================
--- llvm/test/CodeGen/X86/xor.ll
+++ llvm/test/CodeGen/X86/xor.ll
@@ -419,15 +419,14 @@
;
; X64-LIN-LABEL: PR17487:
; X64-LIN: # %bb.0:
-; X64-LIN-NEXT: movd %edi, %xmm0
-; X64-LIN-NEXT: pextrw $0, %xmm0, %eax
+; X64-LIN-NEXT: movl %edi, %eax
; X64-LIN-NEXT: andl $1, %eax
; X64-LIN-NEXT: retq
;
; X64-WIN-LABEL: PR17487:
; X64-WIN: # %bb.0:
-; X64-WIN-NEXT: andb $1, %cl
; X64-WIN-NEXT: movzbl %cl, %eax
+; X64-WIN-NEXT: andl $1, %eax
; X64-WIN-NEXT: retq
%tmp = insertelement <2 x i1> undef, i1 %tobool, i32 1
%tmp1 = zext <2 x i1> %tmp to <2 x i64>
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -18675,12 +18675,17 @@
// Determine if the condition we're dealing with is constant.
SDValue SCC = SimplifySetCC(getSetCCResultType(CmpOpVT), N0, N1, CC, DL,
false);
- if (SCC.getNode()) AddToWorklist(SCC.getNode());
-
- if (auto *SCCC = dyn_cast_or_null<ConstantSDNode>(SCC.getNode())) {
- // fold select_cc true, x, y -> x
- // fold select_cc false, x, y -> y
- return !SCCC->isNullValue() ? N2 : N3;
+ if (SCC.getNode()) {
+ if (auto *SCCC = dyn_cast<ConstantSDNode>(SCC.getNode())) {
+ // fold select_cc true, x, y -> x
+ // fold select_cc false, x, y -> y
+ bool isNull = SCCC->isNullValue();
+ SDValue RV = isNull ? N3 : N2;
+ return RV;
+ }
+ // Don't combine. Cleanup SCC. Don't remove input values.
+ HandleSDNode HN0(N0), HN1(N1), HN2(N2), HN3(N3);
+ recursivelyDeleteUnusedNodes(SCC.getNode());
}
if (SDValue V =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57921.185851.patch
Type: text/x-patch
Size: 1856 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190207/55573d1a/attachment.bin>
More information about the llvm-commits
mailing list