One hundred and forty [(Landrace × Yorkshire) × Duroc] barrows and gilts (86.5 ± 1.5 kg) were used in a 28‐day experiment in a randomised complete block design. A model of gastric ulcer was established by adding aspirin to the diet or by fasting. The five dietary treatments were TRT1 (basal diet), TRT2 (basal diet + fasting), TRT3 (basal diet + 0.05% vitamin U and antacids (VA)), TRT4 (basal diet + aspirin + fasting) and TRT5 (basal diet + aspirin + fasting + 0.1% VA). The active ingredients of VA are vitamin U 50 mg/g, magnesium oxide MgO 60 mg/g, sodium carbonate Na2CO3 70 mg/g. The result showed a significant increase in final body weight (p = 0.047) and average daily gain (p = 0.033) in TRT5 compared with TRT1 and TRT2 (p < 0.05). There was no significant difference in carcass scores among treatment groups (p > 0.05). The stomach keratinisation score was significantly higher in TRT2 and TRT4 than that in TRT3 (p = 0.032). Stomach keratinisation score decreased from 1.9 to 1.4 in TRT5 compared with TRT4 (p > 0.05). In conclusion, the addition of VA to the diet can improve the degree of gastric ulcer to a certain extent and effectively improve growth performance.