This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] convert MIN_EXPR operands to the same type (PR 87059)


On Sat, Aug 25, 2018 at 12:13 PM, Jeff Law <law@redhat.com> wrote:
> On 08/24/2018 01:06 PM, Martin Sebor wrote:
>> PR 87059 points out an ICE in the recently enhanced VRP code
>> that was traced back to a MIN_EXPR built out of operands of
>> types with different sign by expand_builtin_strncmp().
>>
>> The attached patch adjusts the function to make sure both
>> operands have the same type, and to make these mismatches
>> easier to detect, also adds an assertion to fold_binary_loc()
>> for these expressions.
>>
>> Bootstrapped on x86_64-linux.
>>
>> Martin
>>
>> PS Aldy, I have not tested this on powerpc64le.
>>
>> gcc-87059.diff
>>
>>
>> PR tree-optimization/87059 - internal compiler error: in set_value_range
>>
>> gcc/ChangeLog:
>>
>>       PR tree-optimization/87059
>>       * builtins.c (expand_builtin_strncmp): Convert MIN_EXPR operand
>>       to the same type as the other.
>>       * fold-const.c (fold_binary_loc): Assert expectation.
> I bootstrapped (but did not regression test) this on ppc64le and also
> built the linux kernel (which is where my tester tripped over this problem).
>
> Approved and installed on the trunk.

This caused:

[hjl@gnu-skl-1 gcc]$  /export/gnu/import/git/gcc-test/bld/gcc/xgcc
-B/export/gnu/import/git/gcc-test/bld/gcc/
/export/gnu/import/git/gcc-test/src-trunk/gcc/testsuite/gcc.c-torture/execute/builtins/strnlen.c
/export/gnu/import/git/gcc-test/src-trunk/gcc/testsuite/gcc.c-torture/execute/builtins/strnlen-lib.c
/export/gnu/import/git/gcc-test/src-trunk/gcc/testsuite/gcc.c-torture/execute/builtins/lib/main.c
 -w -O -S
during RTL pass: expand
/export/gnu/import/git/gcc-test/src-trunk/gcc/testsuite/gcc.c-torture/execute/builtins/strnlen.c:
In function \u2018test_strnlen_str_range\u2019:
/export/gnu/import/git/gcc-test/src-trunk/gcc/testsuite/gcc.c-torture/execute/builtins/strnlen.c:51:6:
internal compiler error: in fold_binary_loc, at fold-const.c:9333
51 |   A (strnlen ("",     r_0_3) == 0);
   |      ^~~~~~~~~~~~~~~~~~~~~~~
/export/gnu/import/git/gcc-test/src-trunk/gcc/testsuite/gcc.c-torture/execute/builtins/strnlen.c:14:5:
note: in definition of macro \u2018A\u2019
14 |   ((expr) ? (void)0      \
   |     ^~~~
0x61197a fold_binary_loc(unsigned int, tree_code, tree_node*,
tree_node*, tree_node*)
../../src-trunk/gcc/fold-const.c:9333
0xa1ff1a fold_build2_loc(unsigned int, tree_code, tree_node*,
tree_node*, tree_node*)
../../src-trunk/gcc/fold-const.c:12360
0x88b881 expand_builtin_strnlen
../../src-trunk/gcc/builtins.c:3023
0x897d85 expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int)
../../src-trunk/gcc/builtins.c:7331
0x9e2177 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
../../src-trunk/gcc/expr.c:10943
0x9ecf8d expand_expr_real(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
../../src-trunk/gcc/expr.c:8209
0x9ecf8d store_expr(tree_node*, rtx_def*, int, bool, bool)
../../src-trunk/gcc/expr.c:5636
0x9ee887 expand_assignment(tree_node*, tree_node*, bool)
../../src-trunk/gcc/expr.c:5420
0x8ba0a2 expand_call_stmt
../../src-trunk/gcc/cfgexpand.c:2685
0x8ba0a2 expand_gimple_stmt_1
../../src-trunk/gcc/cfgexpand.c:3575
0x8ba0a2 expand_gimple_stmt
../../src-trunk/gcc/cfgexpand.c:3734
0x8bb307 expand_gimple_basic_block
../../src-trunk/gcc/cfgexpand.c:5770
0x8c04f7 execute
../../src-trunk/gcc/cfgexpand.c:6373
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
[hjl@gnu-skl-1 gcc]$


-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]