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: unassignedb...@nondot.org Reporter: spatel+l...@rotateright.com CC: llvm-bugs@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.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs