Started between 20210822 and 20210905, at -O3 or -Ofast : (gcc configured with --enable-checking=yes) $ cat z1.cc typedef void (*p)(); extern "C" p a, b; int f () { int n = 0; for (p* i = &a; i > &b; i++) { n++; } return n; } $ gcc-13-20230212 -c z1.cc -Ofast z1.cc: In function 'int f()': z1.cc:3:5: error: non-trivial conversion in unary operation 3 | int f () { | ^ unsigned long void (*p) (void) * _3 = ~_1; z1.cc:3:5: error: non-trivial conversion in unary operation unsigned long void (*p) (void) * _24 = ~_23; during GIMPLE pass: vect z1.cc:3:5: internal compiler error: verify_gimple failed 0x12942be verify_gimple_in_cfg(function*, bool, bool) ../../gcc/tree-cfg.cc:5648 0x1135053 execute_function_todo ../../gcc/passes.cc:2091 0x1135ad2 execute_todo ../../gcc/passes.cc:2145
Confirmed. Version without function pointers: typedef int *p; extern p a[], b[]; int f () { int n = 0; for (p* i = &a[0]; i > &b[0]; i++) n++; return n; }
I will have a look.
It's caused by -1 -A -> ~A being invoked from number_of_iterations_until_wrap: 1497 num = fold_build2 (MINUS_EXPR, niter_type, wide_int_to_tree (type, max), 1498 iv1->base); (gdb) p iv1->base $3 = <addr_expr 0x7ffff6a77560> (gdb) p niter_type $4 = <integer_type 0x7ffff68e81f8> while _until_wrap probably doesn't make much sense for pointer IVs, the above has signed vs. unsigned type issues anyway.
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:a7e706df2280de4a42f68b6c44401e4348d3593c commit r13-6258-ga7e706df2280de4a42f68b6c44401e4348d3593c Author: Richard Biener <rguenther@suse.de> Date: Mon Feb 20 12:58:50 2023 +0100 tree-optimization/108793 - niter compute type mismatch When computing the number of iterations until wrap types are mixed up, eventually leading to checking ICEs with a pointer bitwise inversion. The following uses niter_type for the calculation. PR tree-optimization/108793 * tree-ssa-loop-niter.cc (number_of_iterations_until_wrap): Use convert operands to niter_type when computing num. * gcc.dg/torture/pr108793.c: New testcase.
Started with r12-3136-g3673dcf6d6baeb67.
The releases/gcc-12 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:0a3642dde799ee2be9f2b60ec361191176390005 commit r12-9259-g0a3642dde799ee2be9f2b60ec361191176390005 Author: Richard Biener <rguenther@suse.de> Date: Mon Feb 20 12:58:50 2023 +0100 tree-optimization/108793 - niter compute type mismatch When computing the number of iterations until wrap types are mixed up, eventually leading to checking ICEs with a pointer bitwise inversion. The following uses niter_type for the calculation. PR tree-optimization/108793 * tree-ssa-loop-niter.cc (number_of_iterations_until_wrap): Use convert operands to niter_type when computing num. * gcc.dg/torture/pr108793.c: New testcase. (cherry picked from commit a7e706df2280de4a42f68b6c44401e4348d3593c)
Fixed.