@@ -1939,51 +1939,8 @@ ConstantFolder::processWorkList() {
1939
1939
// Ok, we have succeeded. Add user to the FoldedUsers list and perform
1940
1940
// the necessary cleanups, RAUWs, etc.
1941
1941
FoldedUsers.insert (User);
1942
- ++NumInstFolded;
1943
-
1944
1942
InvalidateInstructions = true ;
1945
-
1946
- // If the constant produced a tuple, be smarter than RAUW: explicitly
1947
- // nuke any tuple_extract instructions using the apply. This is a
1948
- // common case for functions returning multiple values.
1949
- if (auto *TI = dyn_cast<TupleInst>(C)) {
1950
- for (SILValue Result : User->getResults ()) {
1951
- for (auto UI = Result->use_begin (), UE = Result->use_end ();
1952
- UI != UE;) {
1953
- Operand *O = *UI++;
1954
-
1955
- // If the user is a tuple_extract, just substitute the right
1956
- // value in.
1957
- if (auto *TEI = dyn_cast<TupleExtractInst>(O->getUser ())) {
1958
- SILValue NewVal = TI->getOperand (TEI->getFieldNo ());
1959
- TEI->replaceAllUsesWith (NewVal);
1960
- TEI->dropAllReferences ();
1961
- FoldedUsers.insert (TEI);
1962
- if (auto *Inst = NewVal->getDefiningInstruction ())
1963
- WorkList.insert (Inst);
1964
- continue ;
1965
- }
1966
-
1967
- if (auto *DTI = dyn_cast<DestructureTupleInst>(O->getUser ())) {
1968
- SILValue NewVal = TI->getOperand (O->getOperandNumber ());
1969
- auto OwnershipKind = NewVal.getOwnershipKind ();
1970
- if (OwnershipKind.isCompatibleWith (
1971
- ValueOwnershipKind::Guaranteed)) {
1972
- SILValue DTIResult = DTI->getResult (O->getOperandNumber ());
1973
- DTIResult->replaceAllUsesWith (NewVal);
1974
- FoldedUsers.insert (DTI);
1975
- if (auto *Inst = NewVal->getDefiningInstruction ())
1976
- WorkList.insert (Inst);
1977
- continue ;
1978
- }
1979
- }
1980
- }
1981
- }
1982
-
1983
- if (llvm::all_of (User->getResults (),
1984
- [](SILValue v) { return v->use_empty (); }))
1985
- FoldedUsers.insert (TI);
1986
- }
1943
+ ++NumInstFolded;
1987
1944
1988
1945
// We were able to fold, so all users should use the new folded
1989
1946
// value. If we don't have any such users, continue.
0 commit comments