[llvm-bugs] [Bug 30273] New: [InstCombine] failed to convert selects into add
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Sep 4 13:41:41 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=30273
Bug ID: 30273
Summary: [InstCombine] failed to convert selects into add
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: spatel+llvm at rotateright.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
This example is a simplified test based on actual code in
InstCombineCompares.cpp as of r280624:
$ cat boolcow.c
#include <stdbool.h>
unsigned foo(bool a, bool b) {
unsigned ret = 0;
if (a) ++ret;
if (b) ++ret;
return ret;
}
This is logically equivalent in C99 or C++ to:
unsigned goo(bool a, bool b) {
return a + b;
}
It seems that there's a missing transform in InstCombine itself because the IR
for these two cases is:
$ ./clang -O1 boolcow.c -S -o - -emit-llvm
define i32 @foo(i1 %a, i1 %b) {
%. = zext i1 %a to i32
%inc4 = select i1 %a, i32 2, i32 1
%ret.1 = select i1 %b, i32 %inc4, i32 %.
ret i32 %ret.1
}
define i32 @goo(i1 %a, i1 %b) {
%conv = zext i1 %a to i32
%conv3 = zext i1 %b to i32
%add = add nuw nsw i32 %conv3, %conv
ret i32 %add
}
...so fix this bug, and the compiler might get faster. :)
--
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/20160904/749bb04d/attachment.html>
More information about the llvm-bugs
mailing list