A static analyzer can go through code and find big-O type problems. A developer can go through and refactor the code to make it run more efficiently.
Neither of these tasks requires much context about the larger system.
For example, a function can take a list of contacts and load each one from the database. After loading the contact, it can then load each activity that the contact has done, one at a time. This is a standard nested for loop with O(n^2).
With no further context, you could modify the code to load all of the contacts in a single query. You could then load all of the activity with a second query.
From the perspective of querying the database, the function would go from O(n^2) to O(1). The only context you would need to know is if N could be large enough to exhaust your software’s memory. (There would still be O(n^2) work in memory to assemble the data objects, but that is negligible against the cost of DB calls)
But if you had deeper knowledge you might realize that you don’t need the data in the first place. No database calls are not only faster, but deleting the code is a whole lot easier than refactoring.
AI and other tools make static type efficiency optimizations much easier; but they can’t ask “Should the code even be doing this?” System context is where developers still shine.