comparison gcc/tree-ssa-forwprop.c @ 19:58ad6c70ea60

update gcc from 4.4.0 to 4.4.1.
author kent@firefly.cr.ie.u-ryukyu.ac.jp
date Thu, 24 Sep 2009 13:21:57 +0900
parents a06113de4d67
children 77e2b8dfacca
comparison
equal deleted inserted replaced
18:33936f7f2835 19:58ad6c70ea60
681 { 681 {
682 tree lhs, rhs, rhs2, array_ref; 682 tree lhs, rhs, rhs2, array_ref;
683 tree *rhsp, *lhsp; 683 tree *rhsp, *lhsp;
684 gimple use_stmt = gsi_stmt (*use_stmt_gsi); 684 gimple use_stmt = gsi_stmt (*use_stmt_gsi);
685 enum tree_code rhs_code; 685 enum tree_code rhs_code;
686 bool res = true;
686 687
687 gcc_assert (TREE_CODE (def_rhs) == ADDR_EXPR); 688 gcc_assert (TREE_CODE (def_rhs) == ADDR_EXPR);
688 689
689 lhs = gimple_assign_lhs (use_stmt); 690 lhs = gimple_assign_lhs (use_stmt);
690 rhs_code = gimple_assign_rhs_code (use_stmt); 691 rhs_code = gimple_assign_rhs_code (use_stmt);
724 lhs = *lhsp; 725 lhs = *lhsp;
725 726
726 /* Now see if the LHS node is an INDIRECT_REF using NAME. If so, 727 /* Now see if the LHS node is an INDIRECT_REF using NAME. If so,
727 propagate the ADDR_EXPR into the use of NAME and fold the result. */ 728 propagate the ADDR_EXPR into the use of NAME and fold the result. */
728 if (TREE_CODE (lhs) == INDIRECT_REF 729 if (TREE_CODE (lhs) == INDIRECT_REF
729 && TREE_OPERAND (lhs, 0) == name 730 && TREE_OPERAND (lhs, 0) == name)
730 && may_propagate_address_into_dereference (def_rhs, lhs)
731 && (lhsp != gimple_assign_lhs_ptr (use_stmt)
732 || useless_type_conversion_p (TREE_TYPE (TREE_OPERAND (def_rhs, 0)),
733 TREE_TYPE (rhs))))
734 { 731 {
735 *lhsp = unshare_expr (TREE_OPERAND (def_rhs, 0)); 732 if (may_propagate_address_into_dereference (def_rhs, lhs)
736 fold_stmt_inplace (use_stmt); 733 && (lhsp != gimple_assign_lhs_ptr (use_stmt)
737 tidy_after_forward_propagate_addr (use_stmt); 734 || useless_type_conversion_p
738 735 (TREE_TYPE (TREE_OPERAND (def_rhs, 0)), TREE_TYPE (rhs))))
739 /* Continue propagating into the RHS if this was not the only use. */ 736 {
740 if (single_use_p) 737 *lhsp = unshare_expr (TREE_OPERAND (def_rhs, 0));
741 return true; 738 fold_stmt_inplace (use_stmt);
739 tidy_after_forward_propagate_addr (use_stmt);
740
741 /* Continue propagating into the RHS if this was not the only use. */
742 if (single_use_p)
743 return true;
744 }
745 else
746 /* We can have a struct assignment dereferencing our name twice.
747 Note that we didn't propagate into the lhs to not falsely
748 claim we did when propagating into the rhs. */
749 res = false;
742 } 750 }
743 751
744 /* Strip away any outer COMPONENT_REF, ARRAY_REF or ADDR_EXPR 752 /* Strip away any outer COMPONENT_REF, ARRAY_REF or ADDR_EXPR
745 nodes from the RHS. */ 753 nodes from the RHS. */
746 rhsp = gimple_assign_rhs1_ptr (use_stmt); 754 rhsp = gimple_assign_rhs1_ptr (use_stmt);
756 && may_propagate_address_into_dereference (def_rhs, rhs)) 764 && may_propagate_address_into_dereference (def_rhs, rhs))
757 { 765 {
758 *rhsp = unshare_expr (TREE_OPERAND (def_rhs, 0)); 766 *rhsp = unshare_expr (TREE_OPERAND (def_rhs, 0));
759 fold_stmt_inplace (use_stmt); 767 fold_stmt_inplace (use_stmt);
760 tidy_after_forward_propagate_addr (use_stmt); 768 tidy_after_forward_propagate_addr (use_stmt);
761 return true; 769 return res;
762 } 770 }
763 771
764 /* Now see if the RHS node is an INDIRECT_REF using NAME. If so, 772 /* Now see if the RHS node is an INDIRECT_REF using NAME. If so,
765 propagate the ADDR_EXPR into the use of NAME and try to 773 propagate the ADDR_EXPR into the use of NAME and try to
766 create a VCE and fold the result. */ 774 create a VCE and fold the result. */
787 return false; 795 return false;
788 new_rhs = force_gimple_operand_gsi (use_stmt_gsi, new_rhs, true, NULL, 796 new_rhs = force_gimple_operand_gsi (use_stmt_gsi, new_rhs, true, NULL,
789 true, GSI_NEW_STMT); 797 true, GSI_NEW_STMT);
790 gimple_assign_set_rhs1 (use_stmt, new_rhs); 798 gimple_assign_set_rhs1 (use_stmt, new_rhs);
791 tidy_after_forward_propagate_addr (use_stmt); 799 tidy_after_forward_propagate_addr (use_stmt);
792 return true; 800 return res;
793 } 801 }
794 /* If the defining rhs comes from an indirect reference, then do not 802 /* If the defining rhs comes from an indirect reference, then do not
795 convert into a VIEW_CONVERT_EXPR. */ 803 convert into a VIEW_CONVERT_EXPR. */
796 def_rhs_base = TREE_OPERAND (def_rhs, 0); 804 def_rhs_base = TREE_OPERAND (def_rhs, 0);
797 while (handled_component_p (def_rhs_base)) 805 while (handled_component_p (def_rhs_base))
801 /* We may have arbitrary VIEW_CONVERT_EXPRs in a nested component 809 /* We may have arbitrary VIEW_CONVERT_EXPRs in a nested component
802 reference. Place it there and fold the thing. */ 810 reference. Place it there and fold the thing. */
803 *rhsp = new_rhs; 811 *rhsp = new_rhs;
804 fold_stmt_inplace (use_stmt); 812 fold_stmt_inplace (use_stmt);
805 tidy_after_forward_propagate_addr (use_stmt); 813 tidy_after_forward_propagate_addr (use_stmt);
806 return true; 814 return res;
807 } 815 }
808 } 816 }
809 817
810 /* If the use of the ADDR_EXPR is not a POINTER_PLUS_EXPR, there 818 /* If the use of the ADDR_EXPR is not a POINTER_PLUS_EXPR, there
811 is nothing to do. */ 819 is nothing to do. */