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

            Bug ID: 50218
           Summary: Failed to combine popcount(x) +  popcount(x >> 32) to
                    popcountl(x)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

int test(unsigned long x) {
    return __builtin_popcount(x) +  __builtin_popcount(x >> 32);
}



----------------------------------------
define i32 @src(i64 %0) {
%1:
  %2 = trunc i64 %0 to i32
  %3 = ctpop i32 %2
  %4 = lshr i64 %0, 32
  %5 = trunc i64 %4 to i32
  %6 = ctpop i32 %5
  %7 = add i32 %6, %3
  ret i32 %7
}
=>
define i32 @tgt(i64 %0) {
%1:
  %2 = ctpop i64 %0
  %3 = trunc i64 %2 to i32
  ret i32 %3
}
Transformation seems to be correct!

alive: https://alive2.llvm.org/ce/z/XYSuCb

codegen: https://godbolt.org/z/josqoYEed

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to