dojump.c 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245
  1. /* Convert tree expression to rtl instructions, for GNU compiler.
  2. Copyright (C) 1988-2015 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #include "config.h"
  16. #include "system.h"
  17. #include "coretypes.h"
  18. #include "tm.h"
  19. #include "rtl.h"
  20. #include "hash-set.h"
  21. #include "machmode.h"
  22. #include "vec.h"
  23. #include "double-int.h"
  24. #include "input.h"
  25. #include "alias.h"
  26. #include "symtab.h"
  27. #include "wide-int.h"
  28. #include "inchash.h"
  29. #include "real.h"
  30. #include "tree.h"
  31. #include "fold-const.h"
  32. #include "stor-layout.h"
  33. #include "flags.h"
  34. #include "hard-reg-set.h"
  35. #include "function.h"
  36. #include "insn-config.h"
  37. #include "insn-attr.h"
  38. /* Include expr.h after insn-config.h so we get HAVE_conditional_move. */
  39. #include "hashtab.h"
  40. #include "statistics.h"
  41. #include "fixed-value.h"
  42. #include "expmed.h"
  43. #include "dojump.h"
  44. #include "explow.h"
  45. #include "calls.h"
  46. #include "emit-rtl.h"
  47. #include "varasm.h"
  48. #include "stmt.h"
  49. #include "expr.h"
  50. #include "insn-codes.h"
  51. #include "optabs.h"
  52. #include "langhooks.h"
  53. #include "ggc.h"
  54. #include "predict.h"
  55. #include "basic-block.h"
  56. #include "tm_p.h"
  57. static bool prefer_and_bit_test (machine_mode, int);
  58. static void do_jump_by_parts_greater (tree, tree, int, rtx, rtx, int);
  59. static void do_jump_by_parts_equality (tree, tree, rtx, rtx, int);
  60. static void do_compare_and_jump (tree, tree, enum rtx_code, enum rtx_code, rtx,
  61. rtx, int);
  62. /* Invert probability if there is any. -1 stands for unknown. */
  63. static inline int
  64. inv (int prob)
  65. {
  66. return prob == -1 ? -1 : REG_BR_PROB_BASE - prob;
  67. }
  68. /* At the start of a function, record that we have no previously-pushed
  69. arguments waiting to be popped. */
  70. void
  71. init_pending_stack_adjust (void)
  72. {
  73. pending_stack_adjust = 0;
  74. }
  75. /* Discard any pending stack adjustment. This avoid relying on the
  76. RTL optimizers to remove useless adjustments when we know the
  77. stack pointer value is dead. */
  78. void
  79. discard_pending_stack_adjust (void)
  80. {
  81. stack_pointer_delta -= pending_stack_adjust;
  82. pending_stack_adjust = 0;
  83. }
  84. /* When exiting from function, if safe, clear out any pending stack adjust
  85. so the adjustment won't get done.
  86. Note, if the current function calls alloca, then it must have a
  87. frame pointer regardless of the value of flag_omit_frame_pointer. */
  88. void
  89. clear_pending_stack_adjust (void)
  90. {
  91. if (optimize > 0
  92. && (! flag_omit_frame_pointer || cfun->calls_alloca)
  93. && EXIT_IGNORE_STACK)
  94. discard_pending_stack_adjust ();
  95. }
  96. /* Pop any previously-pushed arguments that have not been popped yet. */
  97. void
  98. do_pending_stack_adjust (void)
  99. {
  100. if (inhibit_defer_pop == 0)
  101. {
  102. if (pending_stack_adjust != 0)
  103. adjust_stack (GEN_INT (pending_stack_adjust));
  104. pending_stack_adjust = 0;
  105. }
  106. }
  107. /* Remember pending_stack_adjust/stack_pointer_delta.
  108. To be used around code that may call do_pending_stack_adjust (),
  109. but the generated code could be discarded e.g. using delete_insns_since. */
  110. void
  111. save_pending_stack_adjust (saved_pending_stack_adjust *save)
  112. {
  113. save->x_pending_stack_adjust = pending_stack_adjust;
  114. save->x_stack_pointer_delta = stack_pointer_delta;
  115. }
  116. /* Restore the saved pending_stack_adjust/stack_pointer_delta. */
  117. void
  118. restore_pending_stack_adjust (saved_pending_stack_adjust *save)
  119. {
  120. if (inhibit_defer_pop == 0)
  121. {
  122. pending_stack_adjust = save->x_pending_stack_adjust;
  123. stack_pointer_delta = save->x_stack_pointer_delta;
  124. }
  125. }
  126. /* Expand conditional expressions. */
  127. /* Generate code to evaluate EXP and jump to LABEL if the value is zero.
  128. LABEL is an rtx of code CODE_LABEL, in this function and all the
  129. functions here. */
  130. void
  131. jumpifnot (tree exp, rtx label, int prob)
  132. {
  133. do_jump (exp, label, NULL_RTX, inv (prob));
  134. }
  135. void
  136. jumpifnot_1 (enum tree_code code, tree op0, tree op1, rtx label, int prob)
  137. {
  138. do_jump_1 (code, op0, op1, label, NULL_RTX, inv (prob));
  139. }
  140. /* Generate code to evaluate EXP and jump to LABEL if the value is nonzero. */
  141. void
  142. jumpif (tree exp, rtx label, int prob)
  143. {
  144. do_jump (exp, NULL_RTX, label, prob);
  145. }
  146. void
  147. jumpif_1 (enum tree_code code, tree op0, tree op1, rtx label, int prob)
  148. {
  149. do_jump_1 (code, op0, op1, NULL_RTX, label, prob);
  150. }
  151. /* Used internally by prefer_and_bit_test. */
  152. static GTY(()) rtx and_reg;
  153. static GTY(()) rtx and_test;
  154. static GTY(()) rtx shift_test;
  155. /* Compare the relative costs of "(X & (1 << BITNUM))" and "(X >> BITNUM) & 1",
  156. where X is an arbitrary register of mode MODE. Return true if the former
  157. is preferred. */
  158. static bool
  159. prefer_and_bit_test (machine_mode mode, int bitnum)
  160. {
  161. bool speed_p;
  162. wide_int mask = wi::set_bit_in_zero (bitnum, GET_MODE_PRECISION (mode));
  163. if (and_test == 0)
  164. {
  165. /* Set up rtxes for the two variations. Use NULL as a placeholder
  166. for the BITNUM-based constants. */
  167. and_reg = gen_rtx_REG (mode, FIRST_PSEUDO_REGISTER);
  168. and_test = gen_rtx_AND (mode, and_reg, NULL);
  169. shift_test = gen_rtx_AND (mode, gen_rtx_ASHIFTRT (mode, and_reg, NULL),
  170. const1_rtx);
  171. }
  172. else
  173. {
  174. /* Change the mode of the previously-created rtxes. */
  175. PUT_MODE (and_reg, mode);
  176. PUT_MODE (and_test, mode);
  177. PUT_MODE (shift_test, mode);
  178. PUT_MODE (XEXP (shift_test, 0), mode);
  179. }
  180. /* Fill in the integers. */
  181. XEXP (and_test, 1) = immed_wide_int_const (mask, mode);
  182. XEXP (XEXP (shift_test, 0), 1) = GEN_INT (bitnum);
  183. speed_p = optimize_insn_for_speed_p ();
  184. return (rtx_cost (and_test, IF_THEN_ELSE, 0, speed_p)
  185. <= rtx_cost (shift_test, IF_THEN_ELSE, 0, speed_p));
  186. }
  187. /* Subroutine of do_jump, dealing with exploded comparisons of the type
  188. OP0 CODE OP1 . IF_FALSE_LABEL and IF_TRUE_LABEL like in do_jump.
  189. PROB is probability of jump to if_true_label, or -1 if unknown. */
  190. void
  191. do_jump_1 (enum tree_code code, tree op0, tree op1,
  192. rtx if_false_label, rtx if_true_label, int prob)
  193. {
  194. machine_mode mode;
  195. rtx_code_label *drop_through_label = 0;
  196. switch (code)
  197. {
  198. case EQ_EXPR:
  199. {
  200. tree inner_type = TREE_TYPE (op0);
  201. gcc_assert (GET_MODE_CLASS (TYPE_MODE (inner_type))
  202. != MODE_COMPLEX_FLOAT);
  203. gcc_assert (GET_MODE_CLASS (TYPE_MODE (inner_type))
  204. != MODE_COMPLEX_INT);
  205. if (integer_zerop (op1))
  206. do_jump (op0, if_true_label, if_false_label, inv (prob));
  207. else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_INT
  208. && !can_compare_p (EQ, TYPE_MODE (inner_type), ccp_jump))
  209. do_jump_by_parts_equality (op0, op1, if_false_label, if_true_label,
  210. prob);
  211. else
  212. do_compare_and_jump (op0, op1, EQ, EQ, if_false_label, if_true_label,
  213. prob);
  214. break;
  215. }
  216. case NE_EXPR:
  217. {
  218. tree inner_type = TREE_TYPE (op0);
  219. gcc_assert (GET_MODE_CLASS (TYPE_MODE (inner_type))
  220. != MODE_COMPLEX_FLOAT);
  221. gcc_assert (GET_MODE_CLASS (TYPE_MODE (inner_type))
  222. != MODE_COMPLEX_INT);
  223. if (integer_zerop (op1))
  224. do_jump (op0, if_false_label, if_true_label, prob);
  225. else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_INT
  226. && !can_compare_p (NE, TYPE_MODE (inner_type), ccp_jump))
  227. do_jump_by_parts_equality (op0, op1, if_true_label, if_false_label,
  228. inv (prob));
  229. else
  230. do_compare_and_jump (op0, op1, NE, NE, if_false_label, if_true_label,
  231. prob);
  232. break;
  233. }
  234. case LT_EXPR:
  235. mode = TYPE_MODE (TREE_TYPE (op0));
  236. if (GET_MODE_CLASS (mode) == MODE_INT
  237. && ! can_compare_p (LT, mode, ccp_jump))
  238. do_jump_by_parts_greater (op0, op1, 1, if_false_label, if_true_label,
  239. prob);
  240. else
  241. do_compare_and_jump (op0, op1, LT, LTU, if_false_label, if_true_label,
  242. prob);
  243. break;
  244. case LE_EXPR:
  245. mode = TYPE_MODE (TREE_TYPE (op0));
  246. if (GET_MODE_CLASS (mode) == MODE_INT
  247. && ! can_compare_p (LE, mode, ccp_jump))
  248. do_jump_by_parts_greater (op0, op1, 0, if_true_label, if_false_label,
  249. inv (prob));
  250. else
  251. do_compare_and_jump (op0, op1, LE, LEU, if_false_label, if_true_label,
  252. prob);
  253. break;
  254. case GT_EXPR:
  255. mode = TYPE_MODE (TREE_TYPE (op0));
  256. if (GET_MODE_CLASS (mode) == MODE_INT
  257. && ! can_compare_p (GT, mode, ccp_jump))
  258. do_jump_by_parts_greater (op0, op1, 0, if_false_label, if_true_label,
  259. prob);
  260. else
  261. do_compare_and_jump (op0, op1, GT, GTU, if_false_label, if_true_label,
  262. prob);
  263. break;
  264. case GE_EXPR:
  265. mode = TYPE_MODE (TREE_TYPE (op0));
  266. if (GET_MODE_CLASS (mode) == MODE_INT
  267. && ! can_compare_p (GE, mode, ccp_jump))
  268. do_jump_by_parts_greater (op0, op1, 1, if_true_label, if_false_label,
  269. inv (prob));
  270. else
  271. do_compare_and_jump (op0, op1, GE, GEU, if_false_label, if_true_label,
  272. prob);
  273. break;
  274. case ORDERED_EXPR:
  275. do_compare_and_jump (op0, op1, ORDERED, ORDERED,
  276. if_false_label, if_true_label, prob);
  277. break;
  278. case UNORDERED_EXPR:
  279. do_compare_and_jump (op0, op1, UNORDERED, UNORDERED,
  280. if_false_label, if_true_label, prob);
  281. break;
  282. case UNLT_EXPR:
  283. do_compare_and_jump (op0, op1, UNLT, UNLT, if_false_label, if_true_label,
  284. prob);
  285. break;
  286. case UNLE_EXPR:
  287. do_compare_and_jump (op0, op1, UNLE, UNLE, if_false_label, if_true_label,
  288. prob);
  289. break;
  290. case UNGT_EXPR:
  291. do_compare_and_jump (op0, op1, UNGT, UNGT, if_false_label, if_true_label,
  292. prob);
  293. break;
  294. case UNGE_EXPR:
  295. do_compare_and_jump (op0, op1, UNGE, UNGE, if_false_label, if_true_label,
  296. prob);
  297. break;
  298. case UNEQ_EXPR:
  299. do_compare_and_jump (op0, op1, UNEQ, UNEQ, if_false_label, if_true_label,
  300. prob);
  301. break;
  302. case LTGT_EXPR:
  303. do_compare_and_jump (op0, op1, LTGT, LTGT, if_false_label, if_true_label,
  304. prob);
  305. break;
  306. case TRUTH_ANDIF_EXPR:
  307. {
  308. /* Spread the probability that the expression is false evenly between
  309. the two conditions. So the first condition is false half the total
  310. probability of being false. The second condition is false the other
  311. half of the total probability of being false, so its jump has a false
  312. probability of half the total, relative to the probability we
  313. reached it (i.e. the first condition was true). */
  314. int op0_prob = -1;
  315. int op1_prob = -1;
  316. if (prob != -1)
  317. {
  318. int false_prob = inv (prob);
  319. int op0_false_prob = false_prob / 2;
  320. int op1_false_prob = GCOV_COMPUTE_SCALE ((false_prob / 2),
  321. inv (op0_false_prob));
  322. /* Get the probability that each jump below is true. */
  323. op0_prob = inv (op0_false_prob);
  324. op1_prob = inv (op1_false_prob);
  325. }
  326. if (if_false_label == NULL_RTX)
  327. {
  328. drop_through_label = gen_label_rtx ();
  329. do_jump (op0, drop_through_label, NULL_RTX, op0_prob);
  330. do_jump (op1, NULL_RTX, if_true_label, op1_prob);
  331. }
  332. else
  333. {
  334. do_jump (op0, if_false_label, NULL_RTX, op0_prob);
  335. do_jump (op1, if_false_label, if_true_label, op1_prob);
  336. }
  337. break;
  338. }
  339. case TRUTH_ORIF_EXPR:
  340. {
  341. /* Spread the probability evenly between the two conditions. So
  342. the first condition has half the total probability of being true.
  343. The second condition has the other half of the total probability,
  344. so its jump has a probability of half the total, relative to
  345. the probability we reached it (i.e. the first condition was false). */
  346. int op0_prob = -1;
  347. int op1_prob = -1;
  348. if (prob != -1)
  349. {
  350. op0_prob = prob / 2;
  351. op1_prob = GCOV_COMPUTE_SCALE ((prob / 2), inv (op0_prob));
  352. }
  353. if (if_true_label == NULL_RTX)
  354. {
  355. drop_through_label = gen_label_rtx ();
  356. do_jump (op0, NULL_RTX, drop_through_label, op0_prob);
  357. do_jump (op1, if_false_label, NULL_RTX, op1_prob);
  358. }
  359. else
  360. {
  361. do_jump (op0, NULL_RTX, if_true_label, op0_prob);
  362. do_jump (op1, if_false_label, if_true_label, op1_prob);
  363. }
  364. break;
  365. }
  366. default:
  367. gcc_unreachable ();
  368. }
  369. if (drop_through_label)
  370. {
  371. do_pending_stack_adjust ();
  372. emit_label (drop_through_label);
  373. }
  374. }
  375. /* Generate code to evaluate EXP and jump to IF_FALSE_LABEL if
  376. the result is zero, or IF_TRUE_LABEL if the result is one.
  377. Either of IF_FALSE_LABEL and IF_TRUE_LABEL may be zero,
  378. meaning fall through in that case.
  379. do_jump always does any pending stack adjust except when it does not
  380. actually perform a jump. An example where there is no jump
  381. is when EXP is `(foo (), 0)' and IF_FALSE_LABEL is null.
  382. PROB is probability of jump to if_true_label, or -1 if unknown. */
  383. void
  384. do_jump (tree exp, rtx if_false_label, rtx if_true_label, int prob)
  385. {
  386. enum tree_code code = TREE_CODE (exp);
  387. rtx temp;
  388. int i;
  389. tree type;
  390. machine_mode mode;
  391. rtx_code_label *drop_through_label = 0;
  392. switch (code)
  393. {
  394. case ERROR_MARK:
  395. break;
  396. case INTEGER_CST:
  397. temp = integer_zerop (exp) ? if_false_label : if_true_label;
  398. if (temp)
  399. emit_jump (temp);
  400. break;
  401. #if 0
  402. /* This is not true with #pragma weak */
  403. case ADDR_EXPR:
  404. /* The address of something can never be zero. */
  405. if (if_true_label)
  406. emit_jump (if_true_label);
  407. break;
  408. #endif
  409. case NOP_EXPR:
  410. if (TREE_CODE (TREE_OPERAND (exp, 0)) == COMPONENT_REF
  411. || TREE_CODE (TREE_OPERAND (exp, 0)) == BIT_FIELD_REF
  412. || TREE_CODE (TREE_OPERAND (exp, 0)) == ARRAY_REF
  413. || TREE_CODE (TREE_OPERAND (exp, 0)) == ARRAY_RANGE_REF)
  414. goto normal;
  415. case CONVERT_EXPR:
  416. /* If we are narrowing the operand, we have to do the compare in the
  417. narrower mode. */
  418. if ((TYPE_PRECISION (TREE_TYPE (exp))
  419. < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  420. goto normal;
  421. case NON_LVALUE_EXPR:
  422. case ABS_EXPR:
  423. case NEGATE_EXPR:
  424. case LROTATE_EXPR:
  425. case RROTATE_EXPR:
  426. /* These cannot change zero->nonzero or vice versa. */
  427. do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label, prob);
  428. break;
  429. case TRUTH_NOT_EXPR:
  430. do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label,
  431. inv (prob));
  432. break;
  433. case COND_EXPR:
  434. {
  435. rtx_code_label *label1 = gen_label_rtx ();
  436. if (!if_true_label || !if_false_label)
  437. {
  438. drop_through_label = gen_label_rtx ();
  439. if (!if_true_label)
  440. if_true_label = drop_through_label;
  441. if (!if_false_label)
  442. if_false_label = drop_through_label;
  443. }
  444. do_pending_stack_adjust ();
  445. do_jump (TREE_OPERAND (exp, 0), label1, NULL_RTX, -1);
  446. do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label, prob);
  447. emit_label (label1);
  448. do_jump (TREE_OPERAND (exp, 2), if_false_label, if_true_label, prob);
  449. break;
  450. }
  451. case COMPOUND_EXPR:
  452. /* Lowered by gimplify.c. */
  453. gcc_unreachable ();
  454. case MINUS_EXPR:
  455. /* Nonzero iff operands of minus differ. */
  456. code = NE_EXPR;
  457. /* FALLTHRU */
  458. case EQ_EXPR:
  459. case NE_EXPR:
  460. case LT_EXPR:
  461. case LE_EXPR:
  462. case GT_EXPR:
  463. case GE_EXPR:
  464. case ORDERED_EXPR:
  465. case UNORDERED_EXPR:
  466. case UNLT_EXPR:
  467. case UNLE_EXPR:
  468. case UNGT_EXPR:
  469. case UNGE_EXPR:
  470. case UNEQ_EXPR:
  471. case LTGT_EXPR:
  472. case TRUTH_ANDIF_EXPR:
  473. case TRUTH_ORIF_EXPR:
  474. other_code:
  475. do_jump_1 (code, TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1),
  476. if_false_label, if_true_label, prob);
  477. break;
  478. case BIT_AND_EXPR:
  479. /* fold_single_bit_test() converts (X & (1 << C)) into (X >> C) & 1.
  480. See if the former is preferred for jump tests and restore it
  481. if so. */
  482. if (integer_onep (TREE_OPERAND (exp, 1)))
  483. {
  484. tree exp0 = TREE_OPERAND (exp, 0);
  485. rtx set_label, clr_label;
  486. int setclr_prob = prob;
  487. /* Strip narrowing integral type conversions. */
  488. while (CONVERT_EXPR_P (exp0)
  489. && TREE_OPERAND (exp0, 0) != error_mark_node
  490. && TYPE_PRECISION (TREE_TYPE (exp0))
  491. <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp0, 0))))
  492. exp0 = TREE_OPERAND (exp0, 0);
  493. /* "exp0 ^ 1" inverts the sense of the single bit test. */
  494. if (TREE_CODE (exp0) == BIT_XOR_EXPR
  495. && integer_onep (TREE_OPERAND (exp0, 1)))
  496. {
  497. exp0 = TREE_OPERAND (exp0, 0);
  498. clr_label = if_true_label;
  499. set_label = if_false_label;
  500. setclr_prob = inv (prob);
  501. }
  502. else
  503. {
  504. clr_label = if_false_label;
  505. set_label = if_true_label;
  506. }
  507. if (TREE_CODE (exp0) == RSHIFT_EXPR)
  508. {
  509. tree arg = TREE_OPERAND (exp0, 0);
  510. tree shift = TREE_OPERAND (exp0, 1);
  511. tree argtype = TREE_TYPE (arg);
  512. if (TREE_CODE (shift) == INTEGER_CST
  513. && compare_tree_int (shift, 0) >= 0
  514. && compare_tree_int (shift, HOST_BITS_PER_WIDE_INT) < 0
  515. && prefer_and_bit_test (TYPE_MODE (argtype),
  516. TREE_INT_CST_LOW (shift)))
  517. {
  518. unsigned HOST_WIDE_INT mask
  519. = (unsigned HOST_WIDE_INT) 1 << TREE_INT_CST_LOW (shift);
  520. do_jump (build2 (BIT_AND_EXPR, argtype, arg,
  521. build_int_cstu (argtype, mask)),
  522. clr_label, set_label, setclr_prob);
  523. break;
  524. }
  525. }
  526. }
  527. /* If we are AND'ing with a small constant, do this comparison in the
  528. smallest type that fits. If the machine doesn't have comparisons
  529. that small, it will be converted back to the wider comparison.
  530. This helps if we are testing the sign bit of a narrower object.
  531. combine can't do this for us because it can't know whether a
  532. ZERO_EXTRACT or a compare in a smaller mode exists, but we do. */
  533. if (! SLOW_BYTE_ACCESS
  534. && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  535. && TYPE_PRECISION (TREE_TYPE (exp)) <= HOST_BITS_PER_WIDE_INT
  536. && (i = tree_floor_log2 (TREE_OPERAND (exp, 1))) >= 0
  537. && (mode = mode_for_size (i + 1, MODE_INT, 0)) != BLKmode
  538. && (type = lang_hooks.types.type_for_mode (mode, 1)) != 0
  539. && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp))
  540. && have_insn_for (COMPARE, TYPE_MODE (type)))
  541. {
  542. do_jump (fold_convert (type, exp), if_false_label, if_true_label,
  543. prob);
  544. break;
  545. }
  546. if (TYPE_PRECISION (TREE_TYPE (exp)) > 1
  547. || TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  548. goto normal;
  549. /* Boolean comparisons can be compiled as TRUTH_AND_EXPR. */
  550. case TRUTH_AND_EXPR:
  551. /* High branch cost, expand as the bitwise AND of the conditions.
  552. Do the same if the RHS has side effects, because we're effectively
  553. turning a TRUTH_AND_EXPR into a TRUTH_ANDIF_EXPR. */
  554. if (BRANCH_COST (optimize_insn_for_speed_p (),
  555. false) >= 4
  556. || TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 1)))
  557. goto normal;
  558. code = TRUTH_ANDIF_EXPR;
  559. goto other_code;
  560. case BIT_IOR_EXPR:
  561. case TRUTH_OR_EXPR:
  562. /* High branch cost, expand as the bitwise OR of the conditions.
  563. Do the same if the RHS has side effects, because we're effectively
  564. turning a TRUTH_OR_EXPR into a TRUTH_ORIF_EXPR. */
  565. if (BRANCH_COST (optimize_insn_for_speed_p (), false) >= 4
  566. || TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 1)))
  567. goto normal;
  568. code = TRUTH_ORIF_EXPR;
  569. goto other_code;
  570. /* Fall through and generate the normal code. */
  571. default:
  572. normal:
  573. temp = expand_normal (exp);
  574. do_pending_stack_adjust ();
  575. /* The RTL optimizers prefer comparisons against pseudos. */
  576. if (GET_CODE (temp) == SUBREG)
  577. {
  578. /* Compare promoted variables in their promoted mode. */
  579. if (SUBREG_PROMOTED_VAR_P (temp)
  580. && REG_P (XEXP (temp, 0)))
  581. temp = XEXP (temp, 0);
  582. else
  583. temp = copy_to_reg (temp);
  584. }
  585. do_compare_rtx_and_jump (temp, CONST0_RTX (GET_MODE (temp)),
  586. NE, TYPE_UNSIGNED (TREE_TYPE (exp)),
  587. GET_MODE (temp), NULL_RTX,
  588. if_false_label, if_true_label, prob);
  589. }
  590. if (drop_through_label)
  591. {
  592. do_pending_stack_adjust ();
  593. emit_label (drop_through_label);
  594. }
  595. }
  596. /* Compare OP0 with OP1, word at a time, in mode MODE.
  597. UNSIGNEDP says to do unsigned comparison.
  598. Jump to IF_TRUE_LABEL if OP0 is greater, IF_FALSE_LABEL otherwise. */
  599. static void
  600. do_jump_by_parts_greater_rtx (machine_mode mode, int unsignedp, rtx op0,
  601. rtx op1, rtx if_false_label, rtx if_true_label,
  602. int prob)
  603. {
  604. int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  605. rtx drop_through_label = 0;
  606. bool drop_through_if_true = false, drop_through_if_false = false;
  607. enum rtx_code code = GT;
  608. int i;
  609. if (! if_true_label || ! if_false_label)
  610. drop_through_label = gen_label_rtx ();
  611. if (! if_true_label)
  612. {
  613. if_true_label = drop_through_label;
  614. drop_through_if_true = true;
  615. }
  616. if (! if_false_label)
  617. {
  618. if_false_label = drop_through_label;
  619. drop_through_if_false = true;
  620. }
  621. /* Deal with the special case 0 > x: only one comparison is necessary and
  622. we reverse it to avoid jumping to the drop-through label. */
  623. if (op0 == const0_rtx && drop_through_if_true && !drop_through_if_false)
  624. {
  625. code = LE;
  626. if_true_label = if_false_label;
  627. if_false_label = drop_through_label;
  628. drop_through_if_true = false;
  629. drop_through_if_false = true;
  630. }
  631. /* Compare a word at a time, high order first. */
  632. for (i = 0; i < nwords; i++)
  633. {
  634. rtx op0_word, op1_word;
  635. if (WORDS_BIG_ENDIAN)
  636. {
  637. op0_word = operand_subword_force (op0, i, mode);
  638. op1_word = operand_subword_force (op1, i, mode);
  639. }
  640. else
  641. {
  642. op0_word = operand_subword_force (op0, nwords - 1 - i, mode);
  643. op1_word = operand_subword_force (op1, nwords - 1 - i, mode);
  644. }
  645. /* All but high-order word must be compared as unsigned. */
  646. do_compare_rtx_and_jump (op0_word, op1_word, code, (unsignedp || i > 0),
  647. word_mode, NULL_RTX, NULL_RTX, if_true_label,
  648. prob);
  649. /* Emit only one comparison for 0. Do not emit the last cond jump. */
  650. if (op0 == const0_rtx || i == nwords - 1)
  651. break;
  652. /* Consider lower words only if these are equal. */
  653. do_compare_rtx_and_jump (op0_word, op1_word, NE, unsignedp, word_mode,
  654. NULL_RTX, NULL_RTX, if_false_label, inv (prob));
  655. }
  656. if (!drop_through_if_false)
  657. emit_jump (if_false_label);
  658. if (drop_through_label)
  659. emit_label (drop_through_label);
  660. }
  661. /* Given a comparison expression EXP for values too wide to be compared
  662. with one insn, test the comparison and jump to the appropriate label.
  663. The code of EXP is ignored; we always test GT if SWAP is 0,
  664. and LT if SWAP is 1. */
  665. static void
  666. do_jump_by_parts_greater (tree treeop0, tree treeop1, int swap,
  667. rtx if_false_label, rtx if_true_label, int prob)
  668. {
  669. rtx op0 = expand_normal (swap ? treeop1 : treeop0);
  670. rtx op1 = expand_normal (swap ? treeop0 : treeop1);
  671. machine_mode mode = TYPE_MODE (TREE_TYPE (treeop0));
  672. int unsignedp = TYPE_UNSIGNED (TREE_TYPE (treeop0));
  673. do_jump_by_parts_greater_rtx (mode, unsignedp, op0, op1, if_false_label,
  674. if_true_label, prob);
  675. }
  676. /* Jump according to whether OP0 is 0. We assume that OP0 has an integer
  677. mode, MODE, that is too wide for the available compare insns. Either
  678. Either (but not both) of IF_TRUE_LABEL and IF_FALSE_LABEL may be NULL_RTX
  679. to indicate drop through. */
  680. static void
  681. do_jump_by_parts_zero_rtx (machine_mode mode, rtx op0,
  682. rtx if_false_label, rtx if_true_label, int prob)
  683. {
  684. int nwords = GET_MODE_SIZE (mode) / UNITS_PER_WORD;
  685. rtx part;
  686. int i;
  687. rtx drop_through_label = 0;
  688. /* The fastest way of doing this comparison on almost any machine is to
  689. "or" all the words and compare the result. If all have to be loaded
  690. from memory and this is a very wide item, it's possible this may
  691. be slower, but that's highly unlikely. */
  692. part = gen_reg_rtx (word_mode);
  693. emit_move_insn (part, operand_subword_force (op0, 0, mode));
  694. for (i = 1; i < nwords && part != 0; i++)
  695. part = expand_binop (word_mode, ior_optab, part,
  696. operand_subword_force (op0, i, mode),
  697. part, 1, OPTAB_WIDEN);
  698. if (part != 0)
  699. {
  700. do_compare_rtx_and_jump (part, const0_rtx, EQ, 1, word_mode,
  701. NULL_RTX, if_false_label, if_true_label, prob);
  702. return;
  703. }
  704. /* If we couldn't do the "or" simply, do this with a series of compares. */
  705. if (! if_false_label)
  706. drop_through_label = if_false_label = gen_label_rtx ();
  707. for (i = 0; i < nwords; i++)
  708. do_compare_rtx_and_jump (operand_subword_force (op0, i, mode),
  709. const0_rtx, EQ, 1, word_mode, NULL_RTX,
  710. if_false_label, NULL_RTX, prob);
  711. if (if_true_label)
  712. emit_jump (if_true_label);
  713. if (drop_through_label)
  714. emit_label (drop_through_label);
  715. }
  716. /* Test for the equality of two RTX expressions OP0 and OP1 in mode MODE,
  717. where MODE is an integer mode too wide to be compared with one insn.
  718. Either (but not both) of IF_TRUE_LABEL and IF_FALSE_LABEL may be NULL_RTX
  719. to indicate drop through. */
  720. static void
  721. do_jump_by_parts_equality_rtx (machine_mode mode, rtx op0, rtx op1,
  722. rtx if_false_label, rtx if_true_label, int prob)
  723. {
  724. int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  725. rtx drop_through_label = 0;
  726. int i;
  727. if (op1 == const0_rtx)
  728. {
  729. do_jump_by_parts_zero_rtx (mode, op0, if_false_label, if_true_label,
  730. prob);
  731. return;
  732. }
  733. else if (op0 == const0_rtx)
  734. {
  735. do_jump_by_parts_zero_rtx (mode, op1, if_false_label, if_true_label,
  736. prob);
  737. return;
  738. }
  739. if (! if_false_label)
  740. drop_through_label = if_false_label = gen_label_rtx ();
  741. for (i = 0; i < nwords; i++)
  742. do_compare_rtx_and_jump (operand_subword_force (op0, i, mode),
  743. operand_subword_force (op1, i, mode),
  744. EQ, 0, word_mode, NULL_RTX,
  745. if_false_label, NULL_RTX, prob);
  746. if (if_true_label)
  747. emit_jump (if_true_label);
  748. if (drop_through_label)
  749. emit_label (drop_through_label);
  750. }
  751. /* Given an EQ_EXPR expression EXP for values too wide to be compared
  752. with one insn, test the comparison and jump to the appropriate label. */
  753. static void
  754. do_jump_by_parts_equality (tree treeop0, tree treeop1, rtx if_false_label,
  755. rtx if_true_label, int prob)
  756. {
  757. rtx op0 = expand_normal (treeop0);
  758. rtx op1 = expand_normal (treeop1);
  759. machine_mode mode = TYPE_MODE (TREE_TYPE (treeop0));
  760. do_jump_by_parts_equality_rtx (mode, op0, op1, if_false_label,
  761. if_true_label, prob);
  762. }
  763. /* Split a comparison into two others, the second of which has the other
  764. "orderedness". The first is always ORDERED or UNORDERED if MODE
  765. does not honor NaNs (which means that it can be skipped in that case;
  766. see do_compare_rtx_and_jump).
  767. The two conditions are written in *CODE1 and *CODE2. Return true if
  768. the conditions must be ANDed, false if they must be ORed. */
  769. bool
  770. split_comparison (enum rtx_code code, machine_mode mode,
  771. enum rtx_code *code1, enum rtx_code *code2)
  772. {
  773. switch (code)
  774. {
  775. case LT:
  776. *code1 = ORDERED;
  777. *code2 = UNLT;
  778. return true;
  779. case LE:
  780. *code1 = ORDERED;
  781. *code2 = UNLE;
  782. return true;
  783. case GT:
  784. *code1 = ORDERED;
  785. *code2 = UNGT;
  786. return true;
  787. case GE:
  788. *code1 = ORDERED;
  789. *code2 = UNGE;
  790. return true;
  791. case EQ:
  792. *code1 = ORDERED;
  793. *code2 = UNEQ;
  794. return true;
  795. case NE:
  796. *code1 = UNORDERED;
  797. *code2 = LTGT;
  798. return false;
  799. case UNLT:
  800. *code1 = UNORDERED;
  801. *code2 = LT;
  802. return false;
  803. case UNLE:
  804. *code1 = UNORDERED;
  805. *code2 = LE;
  806. return false;
  807. case UNGT:
  808. *code1 = UNORDERED;
  809. *code2 = GT;
  810. return false;
  811. case UNGE:
  812. *code1 = UNORDERED;
  813. *code2 = GE;
  814. return false;
  815. case UNEQ:
  816. *code1 = UNORDERED;
  817. *code2 = EQ;
  818. return false;
  819. case LTGT:
  820. /* Do not turn a trapping comparison into a non-trapping one. */
  821. if (HONOR_SNANS (mode))
  822. {
  823. *code1 = LT;
  824. *code2 = GT;
  825. return false;
  826. }
  827. else
  828. {
  829. *code1 = ORDERED;
  830. *code2 = NE;
  831. return true;
  832. }
  833. default:
  834. gcc_unreachable ();
  835. }
  836. }
  837. /* Like do_compare_and_jump but expects the values to compare as two rtx's.
  838. The decision as to signed or unsigned comparison must be made by the caller.
  839. If MODE is BLKmode, SIZE is an RTX giving the size of the objects being
  840. compared. */
  841. void
  842. do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp,
  843. machine_mode mode, rtx size, rtx if_false_label,
  844. rtx if_true_label, int prob)
  845. {
  846. rtx tem;
  847. rtx dummy_label = NULL;
  848. /* Reverse the comparison if that is safe and we want to jump if it is
  849. false. Also convert to the reverse comparison if the target can
  850. implement it. */
  851. if ((! if_true_label
  852. || ! can_compare_p (code, mode, ccp_jump))
  853. && (! FLOAT_MODE_P (mode)
  854. || code == ORDERED || code == UNORDERED
  855. || (! HONOR_NANS (mode) && (code == LTGT || code == UNEQ))
  856. || (! HONOR_SNANS (mode) && (code == EQ || code == NE))))
  857. {
  858. enum rtx_code rcode;
  859. if (FLOAT_MODE_P (mode))
  860. rcode = reverse_condition_maybe_unordered (code);
  861. else
  862. rcode = reverse_condition (code);
  863. /* Canonicalize to UNORDERED for the libcall. */
  864. if (can_compare_p (rcode, mode, ccp_jump)
  865. || (code == ORDERED && ! can_compare_p (ORDERED, mode, ccp_jump)))
  866. {
  867. tem = if_true_label;
  868. if_true_label = if_false_label;
  869. if_false_label = tem;
  870. code = rcode;
  871. prob = inv (prob);
  872. }
  873. }
  874. /* If one operand is constant, make it the second one. Only do this
  875. if the other operand is not constant as well. */
  876. if (swap_commutative_operands_p (op0, op1))
  877. {
  878. tem = op0;
  879. op0 = op1;
  880. op1 = tem;
  881. code = swap_condition (code);
  882. }
  883. do_pending_stack_adjust ();
  884. code = unsignedp ? unsigned_condition (code) : code;
  885. if (0 != (tem = simplify_relational_operation (code, mode, VOIDmode,
  886. op0, op1)))
  887. {
  888. if (CONSTANT_P (tem))
  889. {
  890. rtx label = (tem == const0_rtx || tem == CONST0_RTX (mode))
  891. ? if_false_label : if_true_label;
  892. if (label)
  893. emit_jump (label);
  894. return;
  895. }
  896. code = GET_CODE (tem);
  897. mode = GET_MODE (tem);
  898. op0 = XEXP (tem, 0);
  899. op1 = XEXP (tem, 1);
  900. unsignedp = (code == GTU || code == LTU || code == GEU || code == LEU);
  901. }
  902. if (! if_true_label)
  903. dummy_label = if_true_label = gen_label_rtx ();
  904. if (GET_MODE_CLASS (mode) == MODE_INT
  905. && ! can_compare_p (code, mode, ccp_jump))
  906. {
  907. switch (code)
  908. {
  909. case LTU:
  910. do_jump_by_parts_greater_rtx (mode, 1, op1, op0,
  911. if_false_label, if_true_label, prob);
  912. break;
  913. case LEU:
  914. do_jump_by_parts_greater_rtx (mode, 1, op0, op1,
  915. if_true_label, if_false_label,
  916. inv (prob));
  917. break;
  918. case GTU:
  919. do_jump_by_parts_greater_rtx (mode, 1, op0, op1,
  920. if_false_label, if_true_label, prob);
  921. break;
  922. case GEU:
  923. do_jump_by_parts_greater_rtx (mode, 1, op1, op0,
  924. if_true_label, if_false_label,
  925. inv (prob));
  926. break;
  927. case LT:
  928. do_jump_by_parts_greater_rtx (mode, 0, op1, op0,
  929. if_false_label, if_true_label, prob);
  930. break;
  931. case LE:
  932. do_jump_by_parts_greater_rtx (mode, 0, op0, op1,
  933. if_true_label, if_false_label,
  934. inv (prob));
  935. break;
  936. case GT:
  937. do_jump_by_parts_greater_rtx (mode, 0, op0, op1,
  938. if_false_label, if_true_label, prob);
  939. break;
  940. case GE:
  941. do_jump_by_parts_greater_rtx (mode, 0, op1, op0,
  942. if_true_label, if_false_label,
  943. inv (prob));
  944. break;
  945. case EQ:
  946. do_jump_by_parts_equality_rtx (mode, op0, op1, if_false_label,
  947. if_true_label, prob);
  948. break;
  949. case NE:
  950. do_jump_by_parts_equality_rtx (mode, op0, op1, if_true_label,
  951. if_false_label, inv (prob));
  952. break;
  953. default:
  954. gcc_unreachable ();
  955. }
  956. }
  957. else
  958. {
  959. if (SCALAR_FLOAT_MODE_P (mode)
  960. && ! can_compare_p (code, mode, ccp_jump)
  961. && can_compare_p (swap_condition (code), mode, ccp_jump))
  962. {
  963. rtx tmp;
  964. code = swap_condition (code);
  965. tmp = op0;
  966. op0 = op1;
  967. op1 = tmp;
  968. }
  969. else if (SCALAR_FLOAT_MODE_P (mode)
  970. && ! can_compare_p (code, mode, ccp_jump)
  971. /* Never split ORDERED and UNORDERED.
  972. These must be implemented. */
  973. && (code != ORDERED && code != UNORDERED)
  974. /* Split a floating-point comparison if
  975. we can jump on other conditions... */
  976. && (have_insn_for (COMPARE, mode)
  977. /* ... or if there is no libcall for it. */
  978. || code_to_optab (code) == unknown_optab))
  979. {
  980. enum rtx_code first_code;
  981. bool and_them = split_comparison (code, mode, &first_code, &code);
  982. /* If there are no NaNs, the first comparison should always fall
  983. through. */
  984. if (!HONOR_NANS (mode))
  985. gcc_assert (first_code == (and_them ? ORDERED : UNORDERED));
  986. else
  987. {
  988. int first_prob = prob;
  989. if (first_code == UNORDERED)
  990. first_prob = REG_BR_PROB_BASE / 100;
  991. else if (first_code == ORDERED)
  992. first_prob = REG_BR_PROB_BASE - REG_BR_PROB_BASE / 100;
  993. if (and_them)
  994. {
  995. rtx dest_label;
  996. /* If we only jump if true, just bypass the second jump. */
  997. if (! if_false_label)
  998. {
  999. if (! dummy_label)
  1000. dummy_label = gen_label_rtx ();
  1001. dest_label = dummy_label;
  1002. }
  1003. else
  1004. dest_label = if_false_label;
  1005. do_compare_rtx_and_jump (op0, op1, first_code, unsignedp, mode,
  1006. size, dest_label, NULL_RTX,
  1007. first_prob);
  1008. }
  1009. else
  1010. do_compare_rtx_and_jump (op0, op1, first_code, unsignedp, mode,
  1011. size, NULL_RTX, if_true_label,
  1012. first_prob);
  1013. }
  1014. }
  1015. emit_cmp_and_jump_insns (op0, op1, code, size, mode, unsignedp,
  1016. if_true_label, prob);
  1017. }
  1018. if (if_false_label)
  1019. emit_jump (if_false_label);
  1020. if (dummy_label)
  1021. emit_label (dummy_label);
  1022. }
  1023. /* Generate code for a comparison expression EXP (including code to compute
  1024. the values to be compared) and a conditional jump to IF_FALSE_LABEL and/or
  1025. IF_TRUE_LABEL. One of the labels can be NULL_RTX, in which case the
  1026. generated code will drop through.
  1027. SIGNED_CODE should be the rtx operation for this comparison for
  1028. signed data; UNSIGNED_CODE, likewise for use if data is unsigned.
  1029. We force a stack adjustment unless there are currently
  1030. things pushed on the stack that aren't yet used. */
  1031. static void
  1032. do_compare_and_jump (tree treeop0, tree treeop1, enum rtx_code signed_code,
  1033. enum rtx_code unsigned_code, rtx if_false_label,
  1034. rtx if_true_label, int prob)
  1035. {
  1036. rtx op0, op1;
  1037. tree type;
  1038. machine_mode mode;
  1039. int unsignedp;
  1040. enum rtx_code code;
  1041. /* Don't crash if the comparison was erroneous. */
  1042. op0 = expand_normal (treeop0);
  1043. if (TREE_CODE (treeop0) == ERROR_MARK)
  1044. return;
  1045. op1 = expand_normal (treeop1);
  1046. if (TREE_CODE (treeop1) == ERROR_MARK)
  1047. return;
  1048. type = TREE_TYPE (treeop0);
  1049. mode = TYPE_MODE (type);
  1050. if (TREE_CODE (treeop0) == INTEGER_CST
  1051. && (TREE_CODE (treeop1) != INTEGER_CST
  1052. || (GET_MODE_BITSIZE (mode)
  1053. > GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (treeop1))))))
  1054. {
  1055. /* op0 might have been replaced by promoted constant, in which
  1056. case the type of second argument should be used. */
  1057. type = TREE_TYPE (treeop1);
  1058. mode = TYPE_MODE (type);
  1059. }
  1060. unsignedp = TYPE_UNSIGNED (type);
  1061. code = unsignedp ? unsigned_code : signed_code;
  1062. #ifdef HAVE_canonicalize_funcptr_for_compare
  1063. /* If function pointers need to be "canonicalized" before they can
  1064. be reliably compared, then canonicalize them.
  1065. Only do this if *both* sides of the comparison are function pointers.
  1066. If one side isn't, we want a noncanonicalized comparison. See PR
  1067. middle-end/17564. */
  1068. if (HAVE_canonicalize_funcptr_for_compare
  1069. && TREE_CODE (TREE_TYPE (treeop0)) == POINTER_TYPE
  1070. && TREE_CODE (TREE_TYPE (TREE_TYPE (treeop0)))
  1071. == FUNCTION_TYPE
  1072. && TREE_CODE (TREE_TYPE (treeop1)) == POINTER_TYPE
  1073. && TREE_CODE (TREE_TYPE (TREE_TYPE (treeop1)))
  1074. == FUNCTION_TYPE)
  1075. {
  1076. rtx new_op0 = gen_reg_rtx (mode);
  1077. rtx new_op1 = gen_reg_rtx (mode);
  1078. emit_insn (gen_canonicalize_funcptr_for_compare (new_op0, op0));
  1079. op0 = new_op0;
  1080. emit_insn (gen_canonicalize_funcptr_for_compare (new_op1, op1));
  1081. op1 = new_op1;
  1082. }
  1083. #endif
  1084. do_compare_rtx_and_jump (op0, op1, code, unsignedp, mode,
  1085. ((mode == BLKmode)
  1086. ? expr_size (treeop0) : NULL_RTX),
  1087. if_false_label, if_true_label, prob);
  1088. }
  1089. #include "gt-dojump.h"