The eighth amendment, by prohibiting excessive bail, implies that pretrial detention is constitutional in at least some circumstances:
Excessive bail shall not be required, nor excessive fines imposed, nor cruel and unusual punishments inflicted.
Some may be surprised to learn that this was not at all innovative. There is a virtually identical clause in the English Bill of Rights, a century earlier:
That excessive Baile ought not to be required nor excessive Fines imposed nor cruell and unusuall Punishments inflicted.
From this it should be clear that pretrial detention was already widely accepted as necessary in some cases (in fact, it was the norm for centuries), so it is unlikely that anyone thought that the constitution or bill of rights had sought to abolish it.
The assertion that pretrial detention is illegal as a means of punishment follows directly from two principles, namely:
- That the accused is presumed innocent until proven guilty. It is not appropriate to punish someone whose guilt has not been proven.
- That the purpose of pretrial detention, in keeping with the presumption of innocence, is not to punish. Rather, it is primarily intended to secure the presence of the accused at trial and to prevent the person from committing more crimes. Wikipedia has more information at its articles on bail and the eighth amendment's excessive bail clause.
Consequently, there is unlikely to be any case in which the constitutionality of pretrial detention, generally, is at issue. Rather, you will find cases in which particular elements of an individual's pretrial detention are alleged to violate some constitutional right, which, in addition to the protections already mentioned, includes the right to a speedy trial.