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

            Bug ID: 39455
           Summary: Simplify repeated bounds checks to a min/max reduction
                    style pattern
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedb...@nondot.org
          Reporter: llvm-...@redking.me.uk
                CC: llvm-bugs@lists.llvm.org, spatel+l...@rotateright.com

Checking multiple variables against the same value might be more efficiently
performed as just checking the maximum of the variables:

#include <algorithm>
bool foo(int f, int g) { return f < 123 && g < 123; }
bool bar(int f, int g) { return std::max(f, g) < 123; }

The or case might be similarly handled:

#include <algorithm>
bool foo(int f, int g) { return f < 123 || g < 123; }
bool bar(int f, int g) { return std::min(f, g) < 123; }

The higher the number of variables the higher the likelihood that its
performant (a full vector reduction pattern might even be worthwhile).

Float types might benefit similarly (or more as fmin/fmax instructions are more
common).

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

Reply via email to