This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Committed] Fix failure of gcc.dg/fold-cond-1.c on some targets


The following simple patch fixes the failure of the testcase
gcc.dg/fold-cond-1.c on targets where BRANCH_COST is less than two.
This testcase is designed to check that "g ? 1 : h" is transformed
by fold-const.c into "g || h".  On most platforms, this result is
then further transformed into "(g | h) != 0", which is the outcome
that the test case scans for.  Unfortunately, this second transformation
is only applied on machines where a conditional branch is more expensive
than a logical operation.  Unfortunately -mtune=i486 on x86, bfin and
perhaps other places have a cheap BRANCH_COST, so the scan/regexp fails.

This was spotted whilst investigating a PR which affects i486 but not
i686, where it appears as an additional unexpected failure.

The fix below resolves the non-portable aspects of this test, by
instead of checking the outcome, which is machine-dependent, checks
that the original ternary operator has been eliminated.  Although a
slightly weaker check, it confirms the transformation is applied,
and temporarily disabling the "optimization under scrutiny" in
fold-const.c causes both the original and the revised test case to fail.

Tested on i686-pc-linux-gnu.
Committed to mainline as revision 115691.


2006-07-23  Roger Sayle  <roger@eyesopen.com>

	* gcc.dg/fold-cond-1.c: Increase test case portability by checking
	that "g ? 1 : h" doesn't match, instead of checking for "(g | h) != 0"
	which may transformed to "g || h" on some platforms.


Index: testsuite/gcc.dg/fold-cond-1.c
===================================================================
*** testsuite/gcc.dg/fold-cond-1.c	(revision 115258)
--- testsuite/gcc.dg/fold-cond-1.c	(working copy)
*************** _Bool test4(int g, int h)
*** 24,28 ****
  /* { dg-final { scan-tree-dump-times "a != 0 \&\& b != 0" 1 "original" } } */
  /* { dg-final { scan-tree-dump-times "c == 0 \\|\\| d != 0" 1 "original" } } */
  /* { dg-final { scan-tree-dump-times "e == 0 \&\& f != 0" 1 "original" } } */
! /* { dg-final { scan-tree-dump-times "\\(g \\| h\\) != 0" 1 "original" } } */
  /* { dg-final { cleanup-tree-dump "original" } } */
--- 24,29 ----
  /* { dg-final { scan-tree-dump-times "a != 0 \&\& b != 0" 1 "original" } } */
  /* { dg-final { scan-tree-dump-times "c == 0 \\|\\| d != 0" 1 "original" } } */
  /* { dg-final { scan-tree-dump-times "e == 0 \&\& f != 0" 1 "original" } } */
! /* { dg-final { scan-tree-dump-times "g == 0 \\? h != 0 : 1" 0 "original" } } */
! /* { dg-final { scan-tree-dump-times "g != 0 \\? 1 : h != 0" 0 "original" } } */
  /* { dg-final { cleanup-tree-dump "original" } } */


Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]