Bug 78590 - [7 Regression] FAIL: gcc.target/aarch64/advsimd-intrinsics/vget_lane.c in change_zero_ext in combine
Summary: [7 Regression] FAIL: gcc.target/aarch64/advsimd-intrinsics/vget_lane.c in cha...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: 7.0
Assignee: Segher Boessenkool
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2016-11-29 15:25 UTC by ktkachov
Modified: 2016-11-30 08:28 UTC (History)
1 user (show)

See Also:
Host:
Target: aarch64
Build:
Known to work: 6.2.1
Known to fail: 7.0
Last reconfirmed: 2016-11-29 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ktkachov 2016-11-29 15:25:23 UTC
I believe after r242950 in combine we started seeing some ICEs in some __fp16 tests on aarch64:
FAIL: gcc.target/aarch64/advsimd-intrinsics/vget_lane.c

bad.c: In function 'fn1':
bad.c:8:1: internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:908
 }
 ^
0x7fd144 gen_rtx_SUBREG(machine_mode, rtx_def*, int)
        $SRC/gcc/emit-rtl.c:908
0x7fd183 gen_lowpart_SUBREG(machine_mode, rtx_def*)
        $SRC/gcc/emit-rtl.c:924
0x10e46f5 change_zero_ext
        $SRC/gcc/combine.c:11259
0x10e4ca8 recog_for_combine
        $SRC/gcc/combine.c:11345
0x10f0764 try_combine
        $SRC/gcc/combine.c:3501
0x10f4c7f combine_instructions
        $SRC/gcc/combine.c:1265
0x10f4c7f rest_of_handle_combine
        $SRC/gcc/combine.c:14580
0x10f4c7f execute
        $SRC/gcc/combine.c:14625
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

A reduced reproducer is:
int a;
int fn2 ();
void fn3 ();

void fn1() {
  __fp16 b = fn2();
  if (*(unsigned short *)&b != a)
    fn3();
}

ICEs at -O1 on aarch64
Comment 1 ktkachov 2016-11-29 15:28:34 UTC
In the call:
x = gen_lowpart_SUBREG (mode, x);

the x is:
(float_truncate:HF (reg:DF 79))

and mode is SImode.
Comment 2 ktkachov 2016-11-29 15:46:27 UTC
I suspect we want to extend the
&& !paradoxical_subreg_p (XEXP (x, 0))
check to also check REG_P (SUBREG_REG (XEXP (x, 0))).
The pattern processed in this case is:
(set (reg:SI 80)
    (zero_extend:SI (subreg:HI (float_truncate:HF (reg:DF 79)) 0)))
Comment 3 Segher Boessenkool 2016-11-30 08:25:31 UTC
Author: segher
Date: Wed Nov 30 08:24:59 2016
New Revision: 242999

URL: https://gcc.gnu.org/viewcvs?rev=242999&root=gcc&view=rev
Log:
combine: Don't mess with subregs of floating point (PR78590)

PR78590 shows a problem in change_zero_ext, where we change a zero_extend
of a subreg to a logical and.  We should only do this if the thing we are
taking the subreg of is a scalar integer, otherwise we will take a subreg
of (e.g.) a float in a different size, which is nonsensical and hits an
assert.


	PR rtl-optimization/78590
	* combine.c (change_zero_ext): Transform zero_extend of subregs only
	if the subreg_reg is a scalar integer mode.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/combine.c
Comment 4 Segher Boessenkool 2016-11-30 08:28:28 UTC
Fixed.