While trying to build the GCC 5 with GCC 5, I ran into an ICE when building libcpp at -O0. The problem is the C++ front-end was not folding sizeof(a)/sizeof(a[0]) when passed to a function at -O0. The C++ front-end keeps around sizeof until the gimplifier and there is no way to fold the expressions that involve them. So to work around the issue we need to change __builtin_aarch64_im_lane_boundsi to accept an extra argument and change the first two arguments to size_t type so we don't get an extra cast there and do the division inside the compiler itself. Also we don't want to cause an ICE on any source code so I changed the assert to be a sorry if either of the two arguments are not integer constants. OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions and I was able to bootstrap without a modified libcpp. Thanks, Andrew Pinski ChangeLog: * config/aarch64/aarch64-builtins.c (aarch64_init_simd_builtins): Change the first argument type to size_type_node and add another size_type_node. (aarch64_simd_expand_builtin): Handle the new argument to AARCH64_SIMD_BUILTIN_LANE_CHECK and don't ICE but rather print sorry out when the first two arguments are not integer constants. * config/aarch64/arm_neon.h (__AARCH64_LANE_CHECK): Pass the sizeof's directly to __builtin_aarch64_im_lane_boundsi. testsuite/ChangeLog: * c-c++-common/torture/aarch64-vect-lane-1.c: New testcase.