Bug 65418 - [5 Regression] vim miscompilation
Summary: [5 Regression] vim miscompilation
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 5.0
: P1 normal
Target Milestone: 5.0
Assignee: Jakub Jelinek
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2015-03-13 13:32 UTC by Jakub Jelinek
Modified: 2015-03-14 09:57 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-03-13 00:00:00


Attachments
gcc5-pr65418.patch (926 bytes, patch)
2015-03-13 15:59 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2015-03-13 13:32:25 UTC
__attribute__((noinline, noclone)) int
foo (int x)
{
  if (x == '(' - 256 || x == '|' - 256 || x == '&' - 256 || x == 'n' - 256)
     return 1;
  return 0;
}

int
main ()
{
  if (foo ('n' - 256) != 1
      || foo ('(' - 256) != 1
      || foo ('|' - 256) != 1
      || foo ('&' - 256) != 1
      || foo ('q' - 256) != 0)
    __builtin_abort ();
  return 0;
}

is miscompiled at -O2 starting with r216393.
Comment 1 Jakub Jelinek 2015-03-13 15:59:07 UTC
Created attachment 35028 [details]
gcc5-pr65418.patch

Untested fix.
Comment 2 Jakub Jelinek 2015-03-14 09:56:13 UTC
Author: jakub
Date: Sat Mar 14 09:55:41 2015
New Revision: 221434

URL: https://gcc.gnu.org/viewcvs?rev=221434&root=gcc&view=rev
Log:
	PR tree-optimization/65418
	* tree-ssa-reassoc.c (extract_bit_test_mask): If there
	are casts in the first PLUS_EXPR operand, ensure tbias and
	*totallowp are in the inner type.

	* gcc.c-torture/execute/pr65418-1.c: New test.
	* gcc.c-torture/execute/pr65418-2.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr65418-1.c
    trunk/gcc/testsuite/gcc.c-torture/execute/pr65418-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-reassoc.c
Comment 3 Jakub Jelinek 2015-03-14 09:57:09 UTC
Fixed.