Take the following example: short *a; int f(void) { *a = (short)(((int)*a) << 1); }
the Shift should be done in the same type as *a. This is done in simplify_subreg on the RTL level but we really should be able to do it in fold also. -- Summary: (short)(((int)short_var) <<1) should be done in short Product: gcc Version: 4.2.0 Status: UNCONFIRMED Keywords: missed-optimization, TREE Severity: enhancement Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pinskia at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25186