jump.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. /* Optimize jump instructions, for GNU compiler.
  2. Copyright (C) 1987 Free Software Foundation, Inc.
  3. This file is part of GNU CC.
  4. GNU CC is distributed in the hope that it will be useful,
  5. but WITHOUT ANY WARRANTY. No author or distributor
  6. accepts responsibility to anyone for the consequences of using it
  7. or for whether it serves any particular purpose or works at all,
  8. unless he says so in writing. Refer to the GNU CC General Public
  9. License for full details.
  10. Everyone is granted permission to copy, modify and redistribute
  11. GNU CC, but only under the conditions described in the
  12. GNU CC General Public License. A copy of this license is
  13. supposed to have been given to you along with GNU CC so you
  14. can know your rights and responsibilities. It should be in a
  15. file named COPYING. Among other things, the copyright notice
  16. and this notice must be preserved on all copies. */
  17. /* This is the jump-optimization pass of the compiler.
  18. It is run two or three times: once before cse, sometimes once after cse,
  19. and once after reload (before final).
  20. jump_optimize deletes unreachable code and labels that are not used.
  21. It also deletes jumps that jump to the following insn,
  22. and simplifies jumps around unconditional jumps and jumps
  23. to unconditional jumps.
  24. Each CODE_LABEL has a count of the times it is used
  25. stored in the LABEL_NUSES internal field, and each JUMP_INSN
  26. has one label that it refers to stored in the
  27. JUMP_LABEL internal field. With this we can detect labels that
  28. become unused because of the deletion of all the jumps that
  29. formerly used them. The JUMP_LABEL info is sometimes looked
  30. at by later passes.
  31. Optionally, cross-jumping can be done. Currently it is done
  32. only the last time (when after reload and before final).
  33. In fact, the code for cross-jumping now assumes that register
  34. allocation has been done, since it uses `rtx_renumbered_equal_p'.
  35. Jump optimization is done after cse when cse's constant-propagation
  36. causes jumps to become unconditional or to be deleted.
  37. Unreachable loops are not detected here, because the labels
  38. have references and the insns appear reachable from the labels.
  39. find_basic_blocks in flow.c finds and deletes such loops.
  40. The subroutines delete_insn, redirect_jump, invert_jump, next_real_insn
  41. and prev_real_insn are used from other passes as well. */
  42. #include "config.h"
  43. #include "rtl.h"
  44. /* ??? Eventually must record somehow the labels used by jumps
  45. from nested functions. */
  46. /* Pre-record the next or previous real insn for each label?
  47. No, this pass is very fast anyway. */
  48. /* Condense consecutive labels?
  49. This would make life analysis faster, maybe. */
  50. /* Optimize jump y; x: ... y: jumpif... x?
  51. Don't know if it is worth bothering with. */
  52. /* Optimize two cases of conditional jump to conditional jump?
  53. This can never delete any instruction or make anything dead,
  54. or even change what is live at any point.
  55. So perhaps let combiner do it. */
  56. void delete_insn ();
  57. void redirect_jump ();
  58. void invert_jump ();
  59. rtx next_real_insn ();
  60. rtx prev_real_insn ();
  61. static void mark_jump_label ();
  62. static void delete_jump ();
  63. static void invert_exp ();
  64. static void redirect_exp ();
  65. static rtx follow_jumps ();
  66. static int tension_vector_labels ();
  67. static void find_cross_jump ();
  68. /* Delete no-op jumps and optimize jumps to jumps
  69. and jumps around jumps.
  70. Delete unused labels and unreachable code.
  71. If CROSS_JUMP is nonzero, detect matching code
  72. before a jump and its destination and unify them. */
  73. void
  74. jump_optimize (f, cross_jump)
  75. rtx f;
  76. {
  77. register rtx insn;
  78. int changed;
  79. /* Initialize LABEL_NUSES and JUMP_LABEL fields. */
  80. for (insn = f; insn; insn = NEXT_INSN (insn))
  81. {
  82. if (GET_CODE (insn) == CODE_LABEL)
  83. LABEL_NUSES (insn) = 0;
  84. if (GET_CODE (insn) == JUMP_INSN)
  85. JUMP_LABEL (insn) = 0;
  86. }
  87. /* Delete insns following barriers, up to next label. */
  88. for (insn = f; insn; insn = NEXT_INSN (insn))
  89. if (GET_CODE (insn) == BARRIER)
  90. while (1)
  91. {
  92. register rtx next = NEXT_INSN (insn);
  93. if (next == 0 || GET_CODE (next) == CODE_LABEL)
  94. break;
  95. if (GET_CODE (next) == NOTE)
  96. insn = next;
  97. else
  98. delete_insn (next);
  99. }
  100. /* Mark the label each jump jumps to.
  101. Count uses of CODE_LABELs. */
  102. for (insn = f; insn; insn = NEXT_INSN (insn))
  103. if (GET_CODE (insn) == JUMP_INSN)
  104. {
  105. mark_jump_label (PATTERN (insn), insn);
  106. }
  107. /* Delete all labels already not referenced. */
  108. for (insn = f; insn; )
  109. {
  110. register rtx next = NEXT_INSN (insn);
  111. if (GET_CODE (insn) == CODE_LABEL && LABEL_NUSES (insn) == 0)
  112. {
  113. delete_insn (insn);
  114. next = NEXT_INSN (PREV_INSN (insn));
  115. }
  116. insn = next;
  117. }
  118. /* Now iterate optimizing jumps until nothing changes over one pass. */
  119. changed = 1;
  120. while (changed)
  121. {
  122. register rtx next;
  123. changed = 0;
  124. for (insn = f; insn; insn = next)
  125. {
  126. next = NEXT_INSN (insn);
  127. if (GET_CODE (insn) == JUMP_INSN)
  128. {
  129. if (GET_CODE (PATTERN (insn)) == ADDR_VEC)
  130. changed |= tension_vector_labels (PATTERN (insn), 0);
  131. if (GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)
  132. changed |= tension_vector_labels (PATTERN (insn), 1);
  133. }
  134. if (GET_CODE (insn) == JUMP_INSN && JUMP_LABEL (insn))
  135. {
  136. register rtx reallabelprev = prev_real_insn (JUMP_LABEL (insn));
  137. /* Detect Jump to following insn. */
  138. if (reallabelprev == insn && condjump_p (insn))
  139. {
  140. reallabelprev = PREV_INSN (insn);
  141. delete_jump (insn);
  142. changed = 1;
  143. }
  144. /* Detect jumping over an unconditional jump. */
  145. else if (reallabelprev != 0
  146. && GET_CODE (reallabelprev) == JUMP_INSN
  147. && prev_real_insn (reallabelprev) == insn
  148. && no_labels_between_p (insn, reallabelprev)
  149. && simplejump_p (reallabelprev))
  150. {
  151. /* Delete the original unconditional jump (and barrier). */
  152. /* But don't let its destination go with it. */
  153. ++LABEL_NUSES (JUMP_LABEL (reallabelprev));
  154. delete_insn (reallabelprev);
  155. /* Now change the condition, and make it go to the
  156. place the deleted jump went to.
  157. This may cause the label after the deletion to go away.
  158. But now that the unconditional jump and its barrier
  159. are gone, that is ok. */
  160. invert_jump (insn, JUMP_LABEL (reallabelprev));
  161. --LABEL_NUSES (JUMP_LABEL (reallabelprev));
  162. next = insn;
  163. changed = 1;
  164. }
  165. else
  166. {
  167. /* Detect a jump to a jump. */
  168. {
  169. register rtx nlabel = follow_jumps (JUMP_LABEL (insn));
  170. if (nlabel != JUMP_LABEL (insn))
  171. {
  172. redirect_jump (insn, nlabel);
  173. changed = 1;
  174. next = insn;
  175. }
  176. }
  177. /* Now that the jump has been tensioned,
  178. try cross jumping: check for identical code
  179. before the jump and before its target label. */
  180. if (cross_jump && condjump_p (insn))
  181. {
  182. rtx newjpos, newlpos;
  183. find_cross_jump (insn, JUMP_LABEL (insn),
  184. &newjpos, &newlpos);
  185. if (newjpos != 0)
  186. {
  187. register rtx label;
  188. /* Find an existing label at this point
  189. or make a new one if there is none. */
  190. label = PREV_INSN (newlpos);
  191. if (GET_CODE (label) != CODE_LABEL)
  192. {
  193. label = gen_label_rtx ();
  194. emit_label_after (label, PREV_INSN (newlpos));
  195. LABEL_NUSES (label) = 0;
  196. }
  197. /* Make the same jump insn jump to the new point. */
  198. redirect_jump (insn, label);
  199. /* Delete the matching insns before the jump. */
  200. newjpos = PREV_INSN (newjpos);
  201. while (NEXT_INSN (newjpos) != insn)
  202. /* Don't delete line numbers. */
  203. if (GET_CODE (NEXT_INSN (newjpos)) != NOTE)
  204. delete_insn (NEXT_INSN (newjpos));
  205. else
  206. newjpos = NEXT_INSN (newjpos);
  207. changed = 1;
  208. next = insn;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. }
  216. /* Compare the instructions before insn E1 with those before E2.
  217. Find the longest possible equivalent sequences
  218. and store the first insns of those sequences into *F1 and *F2.
  219. Store zero there if no equivalent preceding instructions are found.
  220. We give up if we find a label in stream 1.
  221. Actually we could transfer that label into stream 2. */
  222. static void
  223. find_cross_jump (e1, e2, f1, f2)
  224. rtx e1, e2;
  225. rtx *f1, *f2;
  226. {
  227. register rtx i1 = e1, i2 = e2;
  228. register rtx p1, p2;
  229. int had_pairs = 0;
  230. int nontrivial = 0;
  231. *f1 = 0;
  232. *f2 = 0;
  233. /* This is how it really should work:
  234. Scan backward one insn at a time
  235. and maintain the pair table as showing all corresponding
  236. registers that are not the same number.
  237. Pairs are inserted when the two insns being compared
  238. use different registers.
  239. Pairs are removed when we find two insns being compared
  240. each setting the appropriate member of the pair.
  241. Any other differences disqualify the insns, and we stop.
  242. When the pair table is empty after scanning an insn,
  243. that insn is the beginning of a sequence of equivalent insns.
  244. But what we really do is give up on any sign of a mismatch.
  245. We can't make the pair-table win because it is incorrect
  246. if anything AFTER the original label (E2) refers to those
  247. mismatched registers. (That is, if they aren't really temps.) */
  248. while (1)
  249. {
  250. i1 = PREV_INSN (i1);
  251. while (i1 && GET_CODE (i1) == NOTE)
  252. i1 = PREV_INSN (i1);
  253. i2 = PREV_INSN (i2);
  254. while (i2 && (GET_CODE (i2) == NOTE || GET_CODE (i2) == CODE_LABEL))
  255. i2 = PREV_INSN (i2);
  256. if (i1 == 0 || GET_CODE (i1) == CODE_LABEL || GET_CODE (i1) == BARRIER)
  257. break;
  258. if (i2 == 0 || GET_CODE (i1) != GET_CODE (i2))
  259. break;
  260. /* This is the simplest way to solve the problem
  261. of splitting the code between a (SET (CC0) ...)
  262. and a following conditional jump: don't match jumps.
  263. Combine would see the (SET (CC0) ...) and an unconditional jump
  264. and delete the former. */
  265. if (GET_CODE (i1) == JUMP_INSN)
  266. break;
  267. p1 = PATTERN (i1);
  268. p2 = PATTERN (i2);
  269. if (GET_CODE (p1) != GET_CODE (p2))
  270. break;
  271. if (!rtx_renumbered_equal_p (p1, p2))
  272. break;
  273. if (GET_CODE (p1) != USE && GET_CODE (p1) != CLOBBER)
  274. nontrivial = 1;
  275. if (nontrivial)
  276. *f1 = i1, *f2 = i2;
  277. }
  278. }
  279. /* Return 1 if INSN is an unconditional jump and nothing else. */
  280. static int
  281. simplejump_p (insn)
  282. rtx insn;
  283. {
  284. register rtx x = PATTERN (insn);
  285. if (GET_CODE (x) != SET)
  286. return 0;
  287. if (GET_CODE (SET_DEST (x)) != PC)
  288. return 0;
  289. if (GET_CODE (SET_SRC (x)) != LABEL_REF)
  290. return 0;
  291. return 1;
  292. }
  293. /* Return nonzero if INSN is a (possibly) conditional jump
  294. and nothing more. */
  295. static int
  296. condjump_p (insn)
  297. rtx insn;
  298. {
  299. register rtx x = PATTERN (insn);
  300. if (GET_CODE (x) != SET)
  301. return 0;
  302. if (GET_CODE (SET_DEST (x)) != PC)
  303. return 0;
  304. if (GET_CODE (SET_SRC (x)) == LABEL_REF)
  305. return 1;
  306. if (GET_CODE (SET_SRC (x)) != IF_THEN_ELSE)
  307. return 0;
  308. if (XEXP (SET_SRC (x), 2) == pc_rtx
  309. && GET_CODE (XEXP (SET_SRC (x), 1)) == LABEL_REF)
  310. return 1;
  311. if (XEXP (SET_SRC (x), 1) == pc_rtx
  312. && GET_CODE (XEXP (SET_SRC (x), 2)) == LABEL_REF)
  313. return 1;
  314. return 0;
  315. }
  316. /* Return 1 if in between BEG and END there is no CODE_LABEL insn. */
  317. int
  318. no_labels_between_p (beg, end)
  319. rtx beg, end;
  320. {
  321. register rtx p;
  322. for (p = beg; p != end; p = NEXT_INSN (p))
  323. if (GET_CODE (p) == CODE_LABEL)
  324. return 0;
  325. return 1;
  326. }
  327. /* Return the last INSN, CALL_INSN or JUMP_INSN before LABEL;
  328. or 0, if there is none. */
  329. rtx
  330. prev_real_insn (label)
  331. rtx label;
  332. {
  333. register rtx insn = PREV_INSN (label);
  334. register RTX_CODE code;
  335. while (1)
  336. {
  337. if (insn == 0)
  338. return 0;
  339. code = GET_CODE (insn);
  340. if (code == INSN || code == CALL_INSN || code == JUMP_INSN)
  341. break;
  342. insn = PREV_INSN (insn);
  343. }
  344. return insn;
  345. }
  346. /* Return the next INSN, CALL_INSN or JUMP_INSN after LABEL;
  347. or 0, if there is none. */
  348. rtx
  349. next_real_insn (label)
  350. rtx label;
  351. {
  352. register rtx insn = NEXT_INSN (label);
  353. register RTX_CODE code;
  354. while (1)
  355. {
  356. if (insn == 0)
  357. return insn;
  358. code = GET_CODE (insn);
  359. if (code == INSN || code == CALL_INSN || code == JUMP_INSN)
  360. break;
  361. insn = NEXT_INSN (insn);
  362. }
  363. return insn;
  364. }
  365. /* Follow any unconditional jump at LABEL;
  366. return the ultimate label reached by any such chain of jumps.
  367. If LABEL is not followed by a jump, return LABEL. */
  368. static rtx
  369. follow_jumps (label)
  370. rtx label;
  371. {
  372. register rtx insn;
  373. register rtx next;
  374. register rtx value = label;
  375. register int depth;
  376. for (depth = 0;
  377. (depth < 10
  378. && (insn = next_real_insn (value)) != 0
  379. && GET_CODE (insn) == JUMP_INSN
  380. && JUMP_LABEL (insn) != 0
  381. && (next = NEXT_INSN (insn))
  382. && GET_CODE (next) == BARRIER);
  383. depth++)
  384. {
  385. value = JUMP_LABEL (insn);
  386. }
  387. return value;
  388. }
  389. /* Assuming that field IDX of X is a vector of label_refs,
  390. replace each of them by the ultimate label reached by it.
  391. Return nonzero if a change is made. */
  392. static int
  393. tension_vector_labels (x, idx)
  394. register rtx x;
  395. register int idx;
  396. {
  397. int changed = 0;
  398. register int i;
  399. for (i = XVECLEN (x, idx) - 1; i >= 0; i--)
  400. {
  401. register rtx olabel = XEXP (XVECEXP (x, idx, i), 0);
  402. register rtx nlabel = follow_jumps (olabel);
  403. if (nlabel != olabel)
  404. {
  405. XEXP (XVECEXP (x, idx, i), 0) = nlabel;
  406. ++LABEL_NUSES (nlabel);
  407. if (--LABEL_NUSES (olabel) == 0)
  408. delete_insn (olabel);
  409. changed = 1;
  410. }
  411. }
  412. return changed;
  413. }
  414. /* Find all CODE_LABELs referred to in X,
  415. and increment their use counts.
  416. Also store one of them in JUMP_LABEL (INSN). */
  417. static void
  418. mark_jump_label (x, insn)
  419. register rtx x;
  420. rtx insn;
  421. {
  422. register RTX_CODE code = GET_CODE (x);
  423. register int i;
  424. register char *fmt;
  425. if (code == LABEL_REF)
  426. {
  427. register rtx label = XEXP (x, 0);
  428. if (GET_CODE (label) != CODE_LABEL)
  429. return;
  430. ++LABEL_NUSES (label);
  431. JUMP_LABEL (insn) = label;
  432. return;
  433. }
  434. fmt = GET_RTX_FORMAT (code);
  435. for (i = GET_RTX_LENGTH (code); i >= 0; i--)
  436. {
  437. if (fmt[i] == 'e')
  438. mark_jump_label (XEXP (x, i), insn);
  439. else if (fmt[i] == 'E')
  440. {
  441. register int j;
  442. for (j = 0; j < XVECLEN (x, i); j++)
  443. mark_jump_label (XVECEXP (x, i, j), insn);
  444. }
  445. }
  446. }
  447. /* If all INSN does is set the pc, delete it,
  448. and delete the insn that set the condition codes for it
  449. if that's what the previous thing was. */
  450. static void
  451. delete_jump (insn)
  452. rtx insn;
  453. {
  454. register rtx x = PATTERN (insn);
  455. register rtx prev;
  456. if (GET_CODE (x) == SET
  457. && GET_CODE (SET_DEST (x)) == PC)
  458. {
  459. prev = PREV_INSN (insn);
  460. delete_insn (insn);
  461. /* We assume that at this stage
  462. CC's are always set explicitly
  463. and always immediately before the jump that
  464. will use them. So if the previous insn
  465. exists to set the CC's, delete it. */
  466. while (prev && GET_CODE (prev) == NOTE)
  467. prev = PREV_INSN (prev);
  468. if (prev && GET_CODE (prev) == INSN
  469. && GET_CODE (PATTERN (prev)) == SET
  470. && SET_DEST (PATTERN (prev)) == cc0_rtx)
  471. delete_insn (prev);
  472. }
  473. }
  474. /* Delete insn INSN from the chain of insns
  475. and also update whatever redundant data needs
  476. to be updated as a result. May delete more insns elsewhere. */
  477. void
  478. delete_insn (insn)
  479. register rtx insn;
  480. {
  481. register rtx next = NEXT_INSN (insn);
  482. register rtx prev = PREV_INSN (insn);
  483. /* If instruction is followed by a barrier,
  484. delete the barrier too. */
  485. if (next != 0 && GET_CODE (next) == BARRIER)
  486. next = NEXT_INSN (next);
  487. /* Patch out INSN (and the barrier if any) */
  488. if (prev)
  489. NEXT_INSN (prev) = next;
  490. if (next)
  491. PREV_INSN (next)= prev;
  492. /* If deleting a jump, decrement the count of the label,
  493. and delete the label if it is now unused. */
  494. if (GET_CODE (insn) == JUMP_INSN && JUMP_LABEL (insn))
  495. if (--LABEL_NUSES (JUMP_LABEL (insn)) == 0)
  496. delete_insn (JUMP_LABEL (insn));
  497. while (prev && GET_CODE (prev) == NOTE)
  498. prev = PREV_INSN (prev);
  499. /* After deleting a label, maybe delete code that follows it. */
  500. if (GET_CODE (insn) == CODE_LABEL && prev
  501. && GET_CODE (prev) == BARRIER)
  502. {
  503. register RTX_CODE code;
  504. while (next != 0
  505. && ((code = GET_CODE (next)) == INSN
  506. || code == JUMP_INSN || code == CALL_INSN
  507. || code == NOTE))
  508. {
  509. if (code == NOTE)
  510. prev = next;
  511. else
  512. /* Note: if this deletes a jump, it can cause more
  513. deletion of unreachable code, after a different label.
  514. But the two levels of deletion won't interfere,
  515. because in that case there must be a BARRIER between them,
  516. and we never delete BARRIERs. */
  517. delete_insn (next);
  518. next = NEXT_INSN (prev);
  519. }
  520. }
  521. }
  522. /* Invert the condition of the jump JUMP, and make it jump
  523. to label NLABEL instead of where it jumps now. */
  524. void
  525. invert_jump (jump, nlabel)
  526. rtx jump, nlabel;
  527. {
  528. register rtx olabel = JUMP_LABEL (jump);
  529. invert_exp (PATTERN (jump), olabel, nlabel);
  530. JUMP_LABEL (jump) = nlabel;
  531. ++LABEL_NUSES (nlabel);
  532. INSN_CODE (jump) = -1;
  533. if (--LABEL_NUSES (olabel) == 0)
  534. delete_insn (olabel);
  535. }
  536. /* Invert the jump condition of rtx X,
  537. and replace OLABEL with NLABEL throughout. */
  538. static void
  539. invert_exp (x, olabel, nlabel)
  540. rtx x;
  541. rtx olabel, nlabel;
  542. {
  543. register RTX_CODE code = GET_CODE (x);
  544. register int i;
  545. register char *fmt;
  546. if (code == IF_THEN_ELSE)
  547. {
  548. /* Inverting the jump condition of an IF_THEN_ELSE
  549. means exchanging the THEN-part with the ELSE-part. */
  550. register rtx tem = XEXP (x, 1);
  551. XEXP (x, 1) = XEXP (x, 2);
  552. XEXP (x, 2) = tem;
  553. }
  554. if (code == LABEL_REF)
  555. {
  556. if (XEXP (x, 0) == olabel)
  557. XEXP (x, 0) = nlabel;
  558. return;
  559. }
  560. fmt = GET_RTX_FORMAT (code);
  561. for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  562. {
  563. if (fmt[i] == 'e')
  564. invert_exp (XEXP (x, i), olabel, nlabel);
  565. if (fmt[i] == 'E')
  566. {
  567. register int j;
  568. for (j = 0; j < XVECLEN (x, i); j++)
  569. invert_exp (XVECEXP (x, i, j), olabel, nlabel);
  570. }
  571. }
  572. }
  573. /* Make jump JUMP jump to label NLABEL instead of where it jumps now.
  574. If the old jump target label is unused as a result,
  575. it and the code following it may be deleted. */
  576. void
  577. redirect_jump (jump, nlabel)
  578. rtx jump, nlabel;
  579. {
  580. register rtx olabel = JUMP_LABEL (jump);
  581. if (nlabel == olabel)
  582. return;
  583. redirect_exp (PATTERN (jump), olabel, nlabel);
  584. JUMP_LABEL (jump) = nlabel;
  585. ++LABEL_NUSES (nlabel);
  586. INSN_CODE (jump) = -1;
  587. if (--LABEL_NUSES (olabel) == 0)
  588. delete_insn (olabel);
  589. }
  590. /* Throughout the rtx X,
  591. alter (LABEL_REF OLABEL) to (LABEL_REF NLABEL). */
  592. static void
  593. redirect_exp (x, olabel, nlabel)
  594. rtx x;
  595. rtx olabel, nlabel;
  596. {
  597. register RTX_CODE code = GET_CODE (x);
  598. register int i;
  599. register char *fmt;
  600. if (code == LABEL_REF)
  601. {
  602. if (XEXP (x, 0) == olabel)
  603. XEXP (x, 0) = nlabel;
  604. return;
  605. }
  606. fmt = GET_RTX_FORMAT (code);
  607. for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  608. {
  609. if (fmt[i] == 'e')
  610. redirect_exp (XEXP (x, i), olabel, nlabel);
  611. if (fmt[i] == 'E')
  612. {
  613. register int j;
  614. for (j = 0; j < XVECLEN (x, i); j++)
  615. redirect_exp (XVECEXP (x, i, j), olabel, nlabel);
  616. }
  617. }
  618. }