https://bugs.llvm.org/show_bug.cgi?id=41815

            Bug ID: 41815
           Summary: Value tracking of undefined to remove branches.
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: sland...@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org

The following code does not need a branch, because uninitialized memory has
undefined contents, and certainly shouldn't have one when the popcnt
instruction is supported:

struct get_sparse_ret {
  size_t index;
  bool godefault;
};

struct get_sparse_ret
__getsparse(size_t key, struct sparse_table_entry *map) {
  struct get_sparse_ret ret;
  if ((((key * 64) / 64) * 64)  * 16 > map[0].length) {
    ret.godefault = true;
    return ret;
  }
  ret = __getsparseinbounds(key, map);
  return ret;
}

I could put the if after the function call, but that wouldn't specify that I
don't care about the first return value if the second return value is true (and
C doesn't have an undefined I can set it to to communicate that).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to