Mercurial > hg > CbC > CbC_gcc
comparison gcc/gimple-ssa-backprop.c @ 132:d34655255c78
update gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 10:21:07 +0900 |
parents | 84e7813d76e9 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
130:e108057fa461 | 132:d34655255c78 |
---|---|
1 /* Back-propagation of usage information to definitions. | 1 /* Back-propagation of usage information to definitions. |
2 Copyright (C) 2015-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2015-2018 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GCC. | 4 This file is part of GCC. |
5 | 5 |
6 GCC is free software; you can redistribute it and/or modify | 6 GCC is free software; you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
258 | 258 |
259 /* A bitmap of blocks that we have finished processing in the initial | 259 /* A bitmap of blocks that we have finished processing in the initial |
260 post-order walk. */ | 260 post-order walk. */ |
261 auto_sbitmap m_visited_blocks; | 261 auto_sbitmap m_visited_blocks; |
262 | 262 |
263 /* A bitmap of phis that we have finished processing in the initial | |
264 post-order walk, excluding those from blocks mentioned in | |
265 M_VISITED_BLOCKS. */ | |
266 auto_bitmap m_visited_phis; | |
267 | |
263 /* A worklist of SSA names whose definitions need to be reconsidered. */ | 268 /* A worklist of SSA names whose definitions need to be reconsidered. */ |
264 auto_vec <tree, 64> m_worklist; | 269 auto_vec <tree, 64> m_worklist; |
265 | 270 |
266 /* The SSA names in M_WORKLIST, identified by their SSA_NAME_VERSION. | 271 /* The SSA names in M_WORKLIST, identified by their SSA_NAME_VERSION. |
267 We use a bitmap rather than an sbitmap because most SSA names are | 272 We use a bitmap rather than an sbitmap because most SSA names are |
352 /* The signs of all inputs are ignored. */ | 357 /* The signs of all inputs are ignored. */ |
353 info->flags.ignore_sign = true; | 358 info->flags.ignore_sign = true; |
354 break; | 359 break; |
355 | 360 |
356 CASE_CFN_COPYSIGN: | 361 CASE_CFN_COPYSIGN: |
362 CASE_CFN_COPYSIGN_FN: | |
357 /* The sign of the first input is ignored. */ | 363 /* The sign of the first input is ignored. */ |
358 if (rhs != gimple_call_arg (call, 1)) | 364 if (rhs != gimple_call_arg (call, 1)) |
359 info->flags.ignore_sign = true; | 365 info->flags.ignore_sign = true; |
360 break; | 366 break; |
361 | 367 |
371 info->flags.ignore_sign = true; | 377 info->flags.ignore_sign = true; |
372 break; | 378 break; |
373 } | 379 } |
374 | 380 |
375 CASE_CFN_FMA: | 381 CASE_CFN_FMA: |
382 CASE_CFN_FMA_FN: | |
383 case CFN_FMS: | |
384 case CFN_FNMA: | |
385 case CFN_FNMS: | |
376 /* In X * X + Y, where Y is distinct from X, the sign of X doesn't | 386 /* In X * X + Y, where Y is distinct from X, the sign of X doesn't |
377 matter. */ | 387 matter. */ |
378 if (gimple_call_arg (call, 0) == rhs | 388 if (gimple_call_arg (call, 0) == rhs |
379 && gimple_call_arg (call, 1) == rhs | 389 && gimple_call_arg (call, 1) == rhs |
380 && gimple_call_arg (call, 2) != rhs) | 390 && gimple_call_arg (call, 2) != rhs) |
401 { | 411 { |
402 tree lhs = gimple_assign_lhs (assign); | 412 tree lhs = gimple_assign_lhs (assign); |
403 switch (gimple_assign_rhs_code (assign)) | 413 switch (gimple_assign_rhs_code (assign)) |
404 { | 414 { |
405 case ABS_EXPR: | 415 case ABS_EXPR: |
416 case ABSU_EXPR: | |
406 /* The sign of the input doesn't matter. */ | 417 /* The sign of the input doesn't matter. */ |
407 info->flags.ignore_sign = true; | 418 info->flags.ignore_sign = true; |
408 break; | 419 break; |
409 | 420 |
410 case COND_EXPR: | 421 case COND_EXPR: |
414 { | 425 { |
415 const usage_info *lhs_info = lookup_operand (lhs); | 426 const usage_info *lhs_info = lookup_operand (lhs); |
416 if (lhs_info) | 427 if (lhs_info) |
417 *info = *lhs_info; | 428 *info = *lhs_info; |
418 } | 429 } |
419 break; | |
420 | |
421 case FMA_EXPR: | |
422 /* In X * X + Y, where Y is distinct from X, the sign of X doesn't | |
423 matter. */ | |
424 if (gimple_assign_rhs1 (assign) == rhs | |
425 && gimple_assign_rhs2 (assign) == rhs | |
426 && gimple_assign_rhs3 (assign) != rhs) | |
427 info->flags.ignore_sign = true; | |
428 break; | 430 break; |
429 | 431 |
430 case MULT_EXPR: | 432 case MULT_EXPR: |
431 /* In X * X, the sign of X doesn't matter. */ | 433 /* In X * X, the sign of X doesn't matter. */ |
432 if (gimple_assign_rhs1 (assign) == rhs | 434 if (gimple_assign_rhs1 (assign) == rhs |
492 | 494 |
493 bool | 495 bool |
494 backprop::intersect_uses (tree var, usage_info *info) | 496 backprop::intersect_uses (tree var, usage_info *info) |
495 { | 497 { |
496 imm_use_iterator iter; | 498 imm_use_iterator iter; |
497 gimple *stmt; | 499 use_operand_p use_p; |
498 *info = usage_info::intersection_identity (); | 500 *info = usage_info::intersection_identity (); |
499 FOR_EACH_IMM_USE_STMT (stmt, iter, var) | 501 FOR_EACH_IMM_USE_FAST (use_p, iter, var) |
500 { | 502 { |
503 gimple *stmt = USE_STMT (use_p); | |
501 if (is_gimple_debug (stmt)) | 504 if (is_gimple_debug (stmt)) |
502 continue; | 505 continue; |
503 if (is_a <gphi *> (stmt) | 506 gphi *phi = dyn_cast <gphi *> (stmt); |
504 && !bitmap_bit_p (m_visited_blocks, gimple_bb (stmt)->index)) | 507 if (phi |
508 && !bitmap_bit_p (m_visited_blocks, gimple_bb (phi)->index) | |
509 && !bitmap_bit_p (m_visited_phis, | |
510 SSA_NAME_VERSION (gimple_phi_result (phi)))) | |
505 { | 511 { |
506 /* Skip unprocessed phis. */ | 512 /* Skip unprocessed phis. */ |
507 if (dump_file && (dump_flags & TDF_DETAILS)) | 513 if (dump_file && (dump_flags & TDF_DETAILS)) |
508 { | 514 { |
509 fprintf (dump_file, "[BACKEDGE] "); | 515 fprintf (dump_file, "[BACKEDGE] "); |
510 print_generic_expr (dump_file, var); | 516 print_generic_expr (dump_file, var); |
511 fprintf (dump_file, " in "); | 517 fprintf (dump_file, " in "); |
512 print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM); | 518 print_gimple_stmt (dump_file, phi, 0, TDF_SLIM); |
513 } | 519 } |
514 } | 520 } |
515 else | 521 else |
516 { | 522 { |
517 usage_info subinfo; | 523 usage_info subinfo; |
518 process_use (stmt, var, &subinfo); | 524 process_use (stmt, var, &subinfo); |
519 *info &= subinfo; | 525 *info &= subinfo; |
520 if (!info->is_useful ()) | 526 if (!info->is_useful ()) |
521 { | 527 return false; |
522 BREAK_FROM_IMM_USE_STMT (iter); | |
523 return false; | |
524 } | |
525 } | 528 } |
526 } | 529 } |
527 return true; | 530 return true; |
528 } | 531 } |
529 | 532 |
631 if (lhs && TREE_CODE (lhs) == SSA_NAME) | 634 if (lhs && TREE_CODE (lhs) == SSA_NAME) |
632 process_var (lhs); | 635 process_var (lhs); |
633 } | 636 } |
634 for (gphi_iterator gpi = gsi_start_phis (bb); !gsi_end_p (gpi); | 637 for (gphi_iterator gpi = gsi_start_phis (bb); !gsi_end_p (gpi); |
635 gsi_next (&gpi)) | 638 gsi_next (&gpi)) |
636 process_var (gimple_phi_result (gpi.phi ())); | 639 { |
640 tree result = gimple_phi_result (gpi.phi ()); | |
641 process_var (result); | |
642 bitmap_set_bit (m_visited_phis, SSA_NAME_VERSION (result)); | |
643 } | |
644 bitmap_clear (m_visited_phis); | |
637 } | 645 } |
638 | 646 |
639 /* Delete the definition of VAR, which has no uses. */ | 647 /* Delete the definition of VAR, which has no uses. */ |
640 | 648 |
641 static void | 649 static void |
677 gimple *def_stmt = SSA_NAME_DEF_STMT (rhs); | 685 gimple *def_stmt = SSA_NAME_DEF_STMT (rhs); |
678 if (gassign *assign = dyn_cast <gassign *> (def_stmt)) | 686 if (gassign *assign = dyn_cast <gassign *> (def_stmt)) |
679 switch (gimple_assign_rhs_code (assign)) | 687 switch (gimple_assign_rhs_code (assign)) |
680 { | 688 { |
681 case ABS_EXPR: | 689 case ABS_EXPR: |
690 case ABSU_EXPR: | |
682 case NEGATE_EXPR: | 691 case NEGATE_EXPR: |
683 return gimple_assign_rhs1 (assign); | 692 return gimple_assign_rhs1 (assign); |
684 | 693 |
685 default: | 694 default: |
686 break; | 695 break; |
687 } | 696 } |
688 else if (gcall *call = dyn_cast <gcall *> (def_stmt)) | 697 else if (gcall *call = dyn_cast <gcall *> (def_stmt)) |
689 switch (gimple_call_combined_fn (call)) | 698 switch (gimple_call_combined_fn (call)) |
690 { | 699 { |
691 CASE_CFN_COPYSIGN: | 700 CASE_CFN_COPYSIGN: |
701 CASE_CFN_COPYSIGN_FN: | |
692 return gimple_call_arg (call, 0); | 702 return gimple_call_arg (call, 0); |
693 | 703 |
694 default: | 704 default: |
695 break; | 705 break; |
696 } | 706 } |
724 otherwise. */ | 734 otherwise. */ |
725 | 735 |
726 void | 736 void |
727 backprop::prepare_change (tree var) | 737 backprop::prepare_change (tree var) |
728 { | 738 { |
729 if (MAY_HAVE_DEBUG_STMTS) | 739 if (MAY_HAVE_DEBUG_BIND_STMTS) |
730 insert_debug_temp_for_var_def (NULL, var); | 740 insert_debug_temp_for_var_def (NULL, var); |
731 reset_flow_sensitive_info (var); | 741 reset_flow_sensitive_info (var); |
732 } | 742 } |
733 | 743 |
734 /* STMT has been changed. Give the fold machinery a chance to simplify | 744 /* STMT has been changed. Give the fold machinery a chance to simplify |