http://llvm.org/bugs/show_bug.cgi?id=22020

            Bug ID: 22020
           Summary: Form a switch from a loop if the loop is really
                    switch-like
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

consider:
int f(char C) {
  const char *Str = ",/\\:. \n\t\'-";
  for (int i = 0, e = 10; i < e; ++i) {
    if (Str[i] == C)
      return i;
  }
  return -1;
}

this is another way of writing:
int f(char C) {
  switch (C) {
  case ',':
    return 0;
  case '/':
    return 1;
  case '\\':
    return 2;
  case ':'
    return 3;
  case '.':
    return 4;
  case ' ':
    return 5;
  case '\n':
    return 6;
  case '\t':
    return 7;
  case '\'':
    return 8;
  case '-'
    return 9;
  }
  return -1;
}

we should canonicalize the first to the second.  pathalogical switches should
be *lower* back to loops for performance.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to