If plant defenses experience positive selection when they first evolve, evidence of selection on a gene can place the origin of novel defenses on a phylogeny. Prior research on pyrrolizidine alkaloids (PAs), rare specialized metabolites of Apocynaceae, reconstructed evolution of homospermidine synthase (HSS), an enzyme of PA biosynthesis, to infer a single origin of PAs by showing a single duplication in the MRCA of all known PA-producing species that gave rise to an enzyme with the predicted motif (VXXXD) of a functionally optimized HSS. We follow up by testing the effect of amino acid motif on HSS function, revisiting motif evolution in HSS-like genes, and testing for selection to infer evolution of HSS function. Some evidence supports a single origin of PAs: an IXXXD HSS, similar in function to VXXXD HSS, evolved in the MRCA of all PA-producing species; loss of optimized HSS function occurred multiple times via pseudogenization and perhaps via evolution of an IXXXN motif. Other evidence indicates multiple origins: the VXXXD motif, present in all PA-producing species, evolved two or three times independently; branch-site models suggest that the ancestral IXXXD branch was not under positive selection while some VXXXD branches were; there is no evidence of relaxed selection on putatively impaired HSS-like genes (IXXXN motif); substitutions at sites experiencing positive selection occurred on multiple branches in the HSS-like gene tree, suggesting that HSS function may have been optimized in multiple independent lineages. We discuss how complexity of genotype-phenotype maps confounds inference of phenotypic from genic evolution.