Just to follow on, the Canadian Supreme Court decision is
here and the invalidated patent is
here. What caused the patent to be invalidated was that the patent is basically written to cover a wide array of similar molecules, all derivatives of a central molecular skeleton. Often, minor alterations to a molecule can be made that do not change the behavior of the molecule as a drug. What it appears Pfizer was looking to do here was prevent competitors from developing ED drugs that were simple derivatives of sildenafil (Viagra) (like adding a methyl group or a fluorine atom somewhere it would have no significant effect). That's considered acceptable strategy, and as a result, other ED drugs like vardenafil (Levitra) and tadalafil (Cialis) have differences in their core structures that keep them from infringing.
However, the Canadian court found that Pfizer had failed to essentially zero in on sildenafil with their claims. When it came down to actually stating that this molecule is the one that lab studies have found treats ED, Pfizer only ever mentions the core skeleton (known as "formula I") and never uniquely identifies sildenafil. It mentions sildenafil (not even by name, only by its R groups) in one claim, but never connects it and only it to ED. The court judgement notes that "formula I" represents 260 quintillion possible compounds, and therefore rejected the patent for vagueness.