People who use the drug methamphetamine alter their brain's structure so it may not work as well as it should, US researchers believe.
The drug appeared to change brain volume
Methamphetamine users had bigger brain areas involved in attention, motivation and the control of movement.
They also fared worse in tests of brain function, the University of California, San Diego team found.
If the individual was HIV-positive the impairment was even worse, the American Journal of Psychiatry study found.
However, in those individuals, the volume of certain areas of the brain appeared to shrink, rather than increase.
The brain regions affected by HIV are those that help with higher thought, reasoning, memory and learning.
The researchers studied 103 adults - some who were HIV positive and some who were HIV negative, and who did or did not use methamphetamine, also known as "meth" or "crystal".
The drug is a powerful central nervous system stimulant which increases energy and alertness and decreases appetite.
Brain volume change
Each volunteer had a brain scan taken and completed a battery of tests that examined cognitive skills such as learning and recall, verbal fluency, information processing and motor functioning.
The meth users had increased volumes of the parietal cortex and the basal ganglia in the brain, while those with HIV had smaller than normal volumes of the cerebral cortex, basal ganglia and hippocampus.
All of the abnormalities were linked to poorer performance on the cognitive tests.
The researchers said these alterations and impairments could cause problems in every day life for the individual.
Head of the team Dr Terry Jernigan said: "In HIV-infected people, the cognitive impairments are associated with decreased employment and vocational abilities, difficulties with medication management, impaired driving performance and problems with general activities of daily living, such as managing money.
"The impact of methamphetamine on daily functioning is less well studied, although it is known that abusers of the drug have impaired decision-making abilities.
"These could potentially affect treatment and relapse prevention efforts, as well as things like money management and driving performance," he said.
He recommended more research to find out why both HIV and methamphetamine appeared to be damaging to the brain, particularly as the number of people who use the drug and are also HIV positive is growing.
He said it might be linked to brain inflammation.
Professor Trevor Smart, head of pharmacology at University College London, said: "I'm not surprised by the findings given the way the drug acts in the brain.
"It is relatively well known if you take methamphetamine for a long time, instead of causing an increase in dopamine - which is thought to give the euphoric effect - it causes a decrease with time.
"The basal ganglia is an area where you get a lot of dopamine."
This controls movement and you sometimes see methamphetamine users who get tremors similar to those seen in Parkinson's disease, he said.
Will Nutland from the Terrence Higgins Trust said: "This research adds to the body of evidence that methamphetamine can have long term effects on the health of people with HIV.
"It's important that people with HIV are made aware of the potential dangers."