Commit 62fb101e by Jakub Jelinek Committed by Jakub Jelinek

re PR tree-optimization/60971 (Wrong code when coercing unsigned char to bool)

	PR tree-optimization/60971
	* tree-tailcall.c (process_assignment): Reject conversions which
	reduce precision.

	* c-c++-common/turtore/pr60971.c: New test.

From-SVN: r209900
parent d77f7b19
2014-04-29 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/60971
* tree-tailcall.c (process_assignment): Reject conversions which
reduce precision.
2014-04-29 James Greenhalgh <james.greenhalgh@arm.com>
* calls.c (initialize_argument_information): Always treat
......
2014-04-29 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/60971
* c-c++-common/turtore/pr60971.c: New test.
2014-04-29 Alan Lawrence <alan.lawrence@arm.com>
* gcc.target/aarch64/simd/simd.exp: New file.
......
/* PR tree-optimization/60971 */
/* { dg-do run } */
#ifndef __cplusplus
#define bool _Bool
#endif
volatile unsigned char c;
__attribute__((noinline)) unsigned char
foo (void)
{
return c;
}
__attribute__((noinline)) bool
bar (void)
{
return foo () & 1;
}
int
main ()
{
c = 0x41;
c = bar ();
if (c != 1)
__builtin_abort ();
c = 0x20;
c = bar ();
if (c != 0)
__builtin_abort ();
return 0;
}
......@@ -285,9 +285,19 @@ process_assignment (gimple stmt, gimple_stmt_iterator call, tree *m,
{
/* Reject a tailcall if the type conversion might need
additional code. */
if (gimple_assign_cast_p (stmt)
&& TYPE_MODE (TREE_TYPE (dest)) != TYPE_MODE (TREE_TYPE (src_var)))
return false;
if (gimple_assign_cast_p (stmt))
{
if (TYPE_MODE (TREE_TYPE (dest)) != TYPE_MODE (TREE_TYPE (src_var)))
return false;
/* Even if the type modes are the same, if the precision of the
type is smaller than mode's precision,
reduce_to_bit_field_precision would generate additional code. */
if (INTEGRAL_TYPE_P (TREE_TYPE (dest))
&& (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (dest)))
> TYPE_PRECISION (TREE_TYPE (dest))))
return false;
}
if (src_var != *ass_var)
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment