[llvm-bugs] [Bug 39455] New: Simplify repeated bounds checks to a min/max reduction style pattern
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 26 10:54:06 PDT 2018
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: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: llvm-bugs at lists.llvm.org, spatel+llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181026/49c65e98/attachment.html>
More information about the llvm-bugs
mailing list