https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116510
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
#6 0x000000000187822c in gimple_simplify_226 (res_op=0x7fffffffcd00,
seq=0x7fffffffced0, valueize=0xd13880 <no_follow_ssa_edges(tree_node*)>,
type=0x7ffff741cb28, captures=0x7fffffffa160, cmp=EQ_EXPR) at
gimple-match-9.cc:1994
1994 if (wi::bit_and_not (wi::to_wide (captures[1]), get_nonzero_bits
(captures[0])) != 0
(gdb) p debug_tree(captures[1])
<integer_cst 0x7ffff730fb40 type <integer_type 0x7ffff741c348 unsigned char>
constant 92>
$1 = void
(gdb) p debug_tree(captures[0])
<ssa_name 0x7ffff73086c0
type <integer_type 0x7ffff741c5e8 int public SI
size <integer_cst 0x7ffff741f168 constant 32>
unit-size <integer_cst 0x7ffff741f180 constant 4>
align:32 warn_if_not_align:0 symtab:0 alias-set 1 canonical-type
0x7ffff741c5e8 precision:32 min <integer_cst 0x7ffff741f120 -2147483648> max
<integer_cst 0x7ffff741f138 2147483647>
pointer_to_this <pointer_type 0x7ffff7424b28>>
visited
def_stmt _8 = gg_strescape_i.2_11 & 255;
version:8
ptr-info 0x7ffff733ddb0>
...
(gdb) p debug_tree(switch_cond)
<truth_not_expr 0x7ffff73513a0
type <boolean_type 0x7ffff741cb28 _Bool public unsigned QI
size <integer_cst 0x7ffff741f018 constant 8>
unit-size <integer_cst 0x7ffff741f030 constant 1>
align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff741cb28 precision:1 min <integer_cst 0x7ffff741f270 0> max <integer_cst
0x7ffff741f2a0 1>>
arg:0 <bit_ior_expr 0x7ffff7354320 type <boolean_type 0x7ffff741cb28 _Bool>
arg:0 <eq_expr 0x7ffff7354348 type <boolean_type 0x7ffff741cb28 _Bool>
arg:0 <ssa_name 0x7ffff73086c0 type <integer_type 0x7ffff741c5e8
int>
visited
def_stmt _8 = gg_strescape_i.2_11 & 255;
version:8
ptr-info 0x7ffff733ddb0>
arg:1 <integer_cst 0x7ffff730fb40 constant 92>
t5.c:6:5 start: t5.c:6:5 finish: t5.c:6:10>
arg:1 <eq_expr 0x7ffff7354370 type <boolean_type 0x7ffff741cb28 _Bool>
arg:0 <ssa_name 0x7ffff73086c0>
arg:1 <integer_cst 0x7ffff730fb58 constant 34>
t5.c:6:5 start: t5.c:6:5 finish: t5.c:6:10>
t5.c:6:5 start: t5.c:6:5 finish: t5.c:6:10>
t5.c:6:5 start: t5.c:6:5 finish: t5.c:6:10>
(gdb) p debug_tree((tree)0x7ffff730fb40)
<integer_cst 0x7ffff730fb40 type <integer_type 0x7ffff741c348 unsigned char>
constant 92>
CASE_HIGH/CASE_LOW have a type of `unsigned char` but index is type of `int`.
There is a missing fold_convert in the predicate_bbs on CASE_HIGH/CASE_LOW.
Note one more thing:
+ tree low = build2_loc (loc, GE_EXPR,
+ boolean_type_node,
+ index, CASE_LOW (label));
+ tree high = build2_loc (loc, LE_EXPR,
+ boolean_type_node,
+ index, CASE_HIGH (label));
+ case_cond = build2_loc (loc, TRUTH_AND_EXPR,
+ boolean_type_node,
+ low, high);
Why use TRUTH_AND_EXPR here, just use AND_EXPR .
Likewise, use TRUTH_NOT_EXPR.
+ switch_cond = build1_loc (loc, TRUTH_NOT_EXPR, boolean_type_node,
+ unshare_expr (switch_cond));
Also why not do something like what is done in convert_single_case_switch ?