https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90514

            Bug ID: 90514
           Summary: Issue about enum type in gcc tree
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: JunMa at linux dot alibaba.com
  Target Milestone: ---

For case pr23046.c:

    enum eumtype { ENUM1, ENUM2 };
    void g(const enum eumtype kind );
    void f(long i);
    void g(const enum eumtype kind)
      {
        if ((kind != ENUM1) && (kind != ENUM2))
          f(kind);
      }

 command: gcc -O2  test.c
 and when I dumped kind, I found:

 <ssa_name 0x7ffff0973d80
    type <enumeral_type 0x7ffff0a93738 eumtype readonly unsigned type_0 SI
        size <integer_cst 0x7ffff0969ee8 constant 32>
        unit-size <integer_cst 0x7ffff0969f00 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff0a93738 precision:32 min <integer_cst 0x7ffff0969f18 0> max <integer_cst
0x7ffff0969ed0 4294967295>
        values <tree_list 0x7ffff0a92be0
            purpose <identifier_node 0x7ffff0aa3fa0 ENUM1>
            value <integer_cst 0x7ffff0988048 constant 0>
            chain <tree_list 0x7ffff0a92c08
                purpose <identifier_node 0x7ffff0ab7000 ENUM2>
                value <integer_cst 0x7ffff0988060 constant 1>>> context
<translation_unit_decl 0x7ffff0976c30 pr23046.c>>
    visited var <parm_decl 0x7ffff0ab9100 kind>
    def_stmt GIMPLE_NOP
    version:3>

It looks weird to me, since I think that min/max/precision of TREE_TYPE(kind)
is inverted with TREE_TYPE(TREE_TYPE(kind)).

This cause vrp pass get wrong range info. Also, the code which checks enum type
is out of data.

Reply via email to