Toiling in Torah

Back in my charedi yeshivah days, the Rosh Yeshivah loved reciting the first Rashi of last week's parasha. Im Bechukosai telechu... says Rashi, surely the rest of the passuk talks about keeping mitzvos, so what does this phrase refer to? It means shetihiyu ameilim b'Torah - that you should be toiling in Torah! This fit perfectly with the hashkafah of the yeshivah, that the primary idea of doing Hashem's will is not to be doing all the mitzvos - it's to be shteiging in Gemara, learning Torah for its own sake.
Rashi's point, which is based on Midrash Sifra, is elaborated upon by R. Eliyahu Mizrachi. The verse mentions three concepts: Im Bechukosai telechu, then there is v'es mitzvosai tishmeru, and then v'asisem osam. All these three seem to be speaking about doing mitzvos, which from Chazal's perspective is superfluous. Thus, only the third part, v'asisem osam, is actually referring to doing the mitzvos. The second part is referring to learning Torah in order to know how to do the mitzvos, and the first part is referring to learning Torah for no other purpose.
But when you take a closer look, it's not at all clear that R. Eliyahu Mizrachi is giving the correct explanation of either Rashi or the Sifra.
While there may be other versions of Rashi, the version that we have reads as follows:
רש"י על ויקרא פרק כו פסוק ג
אם בחקתי תלכו - יכול זה קיום המצות כשהוא אומר ואת מצותי תשמרו הרי קיום המצות אמור הא מה אני מקיים אם בחקתי תלכו שתהיו עמלים בתורה:
Here Rashi says that it's v'es mitzvosai tishmeru which refers to keeping mitzvos. He doesn't say that it's v'asisem osam which refers to keeping the mitzvos. And the Sifra says the same:
ספרא פרשת בחוקותי פרשתא א
אם בחקותי תלכו. יכול אילו המצות. כשהוא אומר ואת מצותי תשמרו ועשיתם אותם הרי מצות אמורות. הא מה אני מקיים אם בחוקתי תלכו להיות עמילים בתורה
Accordingly, the Sifra and Rashi are understanding that there are only two parts to the passuk, not three. The second part, v'es mitzvosai tishmeru v'asisem osam, collectively refers to doing the mitzvos. Which means that the first part, Im Bechukosai telechu, refers to toiling in Torah - but what kind of toil? Rashi explains:
רש"י על ויקרא פרק כו פסוק ג
ואת מצותי תשמרו - הוו עמלים בתורה על מנת לשמור ולקיים כמו שנאמר (דברים ה) ולמדתם אותם ושמרתם לעשותם:
It's talking about toiling in Torah in order to be able to know how to do the mitzvos.
All this fits with something that I noticed a few years ago. The notion that the mitzvah of learning Torah is primarily about learning Torah for the sake of learning Torah is of relatively recent origin. To be sure, there was always a concept that there is some Torah study that has no practical application, and is valuable for its own sake, such as Chazal's statements about ben sorer u'moreh. But the primary function of the mitzvah of learning Torah was seen as being in order to know how to do the mitzvos. See this post for a list of Rishonim saying this very clearly. And it seems that Rashi should be added to this list, rather than having a different view.