[Patch, testsuite] Fix pr69941.c test failure for avr

Senthil Kumar Selvaraj senthil_kumar.selvaraj@atmel.com
Wed Oct 5 17:18:00 GMT 2016


Hi,

  The below patch fixes gcc.dg/torture/pr69941.c to pass for
  int size != 32 targets like avr.

  For the avr target, ints are 16 bits wide. VRP concludes
  that a right shift by 9 followed by an equality comparison 
  to 0x74 can never be true, and ends up eliminating the
  conditional. The code ends up unconditionally
  calling __builtin_abort and obviously fails when run.

  The patch fixes the testcase to use __INT32_TYPE__ (via a
  typedef) if __SIZEOF_INT__ is less than 4.

  Regtested with both avr and x86_64, the test passes with
  both targets.

Regards
Senthil

gcc/testsuite/ChangeLog

2016-10-05  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>

        * gcc.dg/torture/pr69941.c: Use __INT32_TYPE__ instead
        of int if __SIZEOF_INT__ is less than 4 bytes.

Index: gcc/testsuite/gcc.dg/torture/pr69941.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr69941.c	(revision 240781)
+++ gcc/testsuite/gcc.dg/torture/pr69941.c	(working copy)
@@ -1,11 +1,17 @@
 /* { dg-do run } */
+
+#if __SIZEOF_INT__ < 4
+__extension__ typedef __INT32_TYPE__ int32_t;
+#else
+typedef int int32_t;
+#endif
  
 int a = 0;
 int b = 0;
 int c = 0;
-int e = 0;
+int32_t e = 0;
 int f = 0;
-int *g = &e;
+int32_t *g = &e;
  
 int fn1() { return b ? a : b; }
  



More information about the Gcc-patches mailing list