X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fbuiltins.c;h=0ffacf9d4454d855ee56bc180b337dee1f4ebccf;hb=2169f33bdc9db9199850a22ce70730c68227b2db;hp=4e0d7937716136390149d2b78fbd9ae93efc651b;hpb=2cc66f2ad8d743ca03465d67871cf157cf3d7124;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/builtins.c b/gcc/builtins.c index 4e0d7937716..0ffacf9d445 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -1238,9 +1238,8 @@ get_memory_rtx (tree exp, tree len) gcc_assert (TREE_CODE (inner) == COMPONENT_REF); - if (MEM_OFFSET (mem) - && CONST_INT_P (MEM_OFFSET (mem))) - offset = INTVAL (MEM_OFFSET (mem)); + if (MEM_OFFSET_KNOWN_P (mem)) + offset = MEM_OFFSET (mem); if (offset >= 0 && len && host_integerp (len, 0)) length = tree_low_cst (len, 0); @@ -1295,11 +1294,14 @@ get_memory_rtx (tree exp, tree len) if (mem_expr != MEM_EXPR (mem)) { set_mem_expr (mem, mem_expr); - set_mem_offset (mem, offset >= 0 ? GEN_INT (offset) : NULL_RTX); + if (offset >= 0) + set_mem_offset (mem, offset); + else + clear_mem_offset (mem); } } set_mem_alias_set (mem, 0); - set_mem_size (mem, NULL_RTX); + clear_mem_size (mem); } return mem; @@ -3691,8 +3693,8 @@ expand_builtin_memcmp (tree exp, ATTRIBUTE_UNUSED rtx target, /* Set MEM_SIZE as appropriate. */ if (CONST_INT_P (arg3_rtx)) { - set_mem_size (arg1_rtx, arg3_rtx); - set_mem_size (arg2_rtx, arg3_rtx); + set_mem_size (arg1_rtx, INTVAL (arg3_rtx)); + set_mem_size (arg2_rtx, INTVAL (arg3_rtx)); } #ifdef HAVE_cmpmemsi @@ -4835,7 +4837,7 @@ expand_builtin_init_trampoline (tree exp) { m_tramp = change_address (m_tramp, BLKmode, tmp); set_mem_align (m_tramp, TRAMPOLINE_ALIGNMENT); - set_mem_size (m_tramp, GEN_INT (TRAMPOLINE_SIZE)); + set_mem_size (m_tramp, TRAMPOLINE_SIZE); } /* The FUNC argument should be the address of the nested function. @@ -6261,13 +6263,22 @@ build_builtin_expect_predicate (location_t loc, tree pred, tree expected) static tree fold_builtin_expect (location_t loc, tree arg0, tree arg1) { - tree inner, fndecl; + tree inner, fndecl, inner_arg0; enum tree_code code; + /* Distribute the expected value over short-circuiting operators. + See through the cast from truthvalue_type_node to long. */ + inner_arg0 = arg0; + while (TREE_CODE (inner_arg0) == NOP_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (inner_arg0)) + && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (inner_arg0, 0)))) + inner_arg0 = TREE_OPERAND (inner_arg0, 0); + /* If this is a builtin_expect within a builtin_expect keep the inner one. See through a comparison against a constant. It might have been added to create a thruthvalue. */ - inner = arg0; + inner = inner_arg0; + if (COMPARISON_CLASS_P (inner) && TREE_CODE (TREE_OPERAND (inner, 1)) == INTEGER_CST) inner = TREE_OPERAND (inner, 0); @@ -6278,14 +6289,7 @@ fold_builtin_expect (location_t loc, tree arg0, tree arg1) && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT) return arg0; - /* Distribute the expected value over short-circuiting operators. - See through the cast from truthvalue_type_node to long. */ - inner = arg0; - while (TREE_CODE (inner) == NOP_EXPR - && INTEGRAL_TYPE_P (TREE_TYPE (inner)) - && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (inner, 0)))) - inner = TREE_OPERAND (inner, 0); - + inner = inner_arg0; code = TREE_CODE (inner); if (code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR) { @@ -6300,13 +6304,13 @@ fold_builtin_expect (location_t loc, tree arg0, tree arg1) } /* If the argument isn't invariant then there's nothing else we can do. */ - if (!TREE_CONSTANT (arg0)) + if (!TREE_CONSTANT (inner_arg0)) return NULL_TREE; /* If we expect that a comparison against the argument will fold to a constant return the constant. In practice, this means a true constant or the address of a non-weak symbol. */ - inner = arg0; + inner = inner_arg0; STRIP_NOPS (inner); if (TREE_CODE (inner) == ADDR_EXPR) { @@ -8641,8 +8645,9 @@ fold_builtin_signbit (location_t loc, tree arg, tree type) /* If ARG's format doesn't have signed zeros, return "arg < 0.0". */ if (!HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg)))) - return fold_build2_loc (loc, LT_EXPR, type, arg, - build_real (TREE_TYPE (arg), dconst0)); + return fold_convert (type, + fold_build2_loc (loc, LT_EXPR, boolean_type_node, arg, + build_real (TREE_TYPE (arg), dconst0))); return NULL_TREE; }