Bug 35809 - default case label for casesi should be sliced off from last element
Summary: default case label for casesi should be sliced off from last element
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2008-04-03 02:44 UTC by Hans-Peter Nilsson
Modified: 2008-10-02 00:14 UTC (History)
2 users (show)

See Also:
Host:
Target: cris-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-04-03 09:52:38


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hans-Peter Nilsson 2008-04-03 02:44:34 UTC
The fix for PR middle-end/35800 was to find a "new" default label as one is required by the casesi pattern, but value-range-propagation had determined that a switch statement can't fall through or reach the default label, so "it was NULL".  The fix was to arbitrarily use the first label of the case-table.  An improvement would be to slice off the last element, shrinking the table and its range.
This naturally only affects targets with casesi patterns.
Comment 1 Richard Biener 2008-04-03 09:52:38 UTC
Confirmed.
Comment 2 Richard Biener 2008-10-01 18:05:27 UTC
This is maybe fixed with the patch for PR37285?
Comment 3 Hans-Peter Nilsson 2008-10-02 00:14:47 UTC
Well, at least partially.  The range is shifted and the number of values *is* now shrunk by one.  Looking at assembly-code for gcc.c-torture/execute/pr35800.c at r140821 reveals that the first case is still arbitrarily taken as the default, where the last one would have been better as it's repeated 32 times.

If instead the last value had been picked as the default, duplicate identical values could have been stripped, like in the pr35800.c test-case (there's 32 identical last cases).  Ok, I'll open a new one. :)