[llvm-bugs] [Bug 41815] New: Value tracking of undefined to remove branches.

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 9 06:26:05 PDT 2019


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: unassignedbugs at nondot.org
          Reporter: slandden at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190509/47a4397e/attachment-0001.html>


More information about the llvm-bugs mailing list