Bug 91725 - [10 Regression] ICE in get_nonzero_bits starting with r275587
Summary: [10 Regression] ICE in get_nonzero_bits starting with r275587
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 9.1.1
: P3 normal
Target Milestone: 10.0
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
: 91743 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-09-10 18:07 UTC by Jakub Jelinek
Modified: 2019-09-11 21:22 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 9.2.0
Known to fail: 10.0
Last reconfirmed: 2019-09-10 00:00:00


Attachments
gcc10-pr91725.patch (641 bytes, patch)
2019-09-10 18:19 UTC, Jakub Jelinek
Details | Diff
gcc10-pr91725.patch (640 bytes, patch)
2019-09-10 20:02 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 2019-09-10 18:07:22 UTC
Apparently my PR91680 fix caused ICE on powerpc64le on Linux kernel (and possibly other architectures).

Simple testcase:
unsigned long long
foo (unsigned long long x, unsigned long long y, int z)
{
  return (x + y) / (1 << z);
}
Comment 1 Jakub Jelinek 2019-09-10 18:19:51 UTC
Created attachment 46864 [details]
gcc10-pr91725.patch

Untested fix.
Comment 2 Marc Glisse 2019-09-10 19:47:37 UTC
(In reply to Jakub Jelinek from comment #1)
> gcc10-pr91725.patch

An alternative (I don't claim it is better) would be to make get_nonzero_bits conservatively return -1 on unknown input, like the comment before it seems to suggest.
Comment 3 Jakub Jelinek 2019-09-10 20:02:46 UTC
Created attachment 46866 [details]
gcc10-pr91725.patch

Yet another untested patch, tree_nonzero_bits is something that already does what you write above, just doesn't cope with vector types (as it uses TYPE_PRECISION rather than element_precision).  But, get_nonzero_bits isn't really useful on vector types anyway, for SSA_NAMEs we don't track the non-zero bits and for VECTOR_CSTs we'd need to test all elements and or the bits together.
Comment 4 Jakub Jelinek 2019-09-11 08:34:27 UTC
Author: jakub
Date: Wed Sep 11 08:33:55 2019
New Revision: 275633

URL: https://gcc.gnu.org/viewcvs?rev=275633&root=gcc&view=rev
Log:
	PR middle-end/91725
	* match.pd ((A / (1 << B)) -> (A >> B)): Call tree_nonzero_bits instead
	of get_nonzero_bits, only call it for integral types.

	* gcc.c-torture/compile/pr91725.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr91725.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/match.pd
    trunk/gcc/testsuite/ChangeLog
Comment 5 Jakub Jelinek 2019-09-11 08:37:05 UTC
Fixed.
Comment 6 Jakub Jelinek 2019-09-11 21:22:51 UTC
*** Bug 91743 has been marked as a duplicate of this bug. ***