[llvm] [InstCombine] Reduce range of ctpop for non zero argument (PR #100899)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 28 17:30:07 PDT 2024
dtcxzyw wrote:
> In the original repro, I am using absl and c++17. https://godbolt.org/z/35c9xfn6h but I can't make executor run this because it can't find absl libraries.
```
define dso_local noundef range(i32 1, -2147483647) i32 @bucket(int)(i32 noundef %0) local_unnamed_addr #4 { %0 -> 0
%2 = tail call i32 @llvm.smax.i32(i32 %0, i32 0) -> 0
%3 = icmp sgt i32 %0, 0 -> false
%4 = tail call range(i32 1, 32) i32 @llvm.ctpop.i32(i32 %2) -> poison
%5 = icmp samesign ult i32 %4, 2 -> poison
%6 = select i1 %3, i1 %5, i1 false -> false
%7 = tail call range(i32 0, 33) i32 @llvm.ctlz.i32(i32 %2, i1 true) -> poison
%8 = add nsw i32 %2, -1 -> -1
%9 = tail call range(i32 0, 33) i32 @llvm.ctlz.i32(i32 %8, i1 false) -> 0
%10 = select i1 %6, i32 %7, i32 %9 -> 0
%11 = sub nsw i32 0, %10 -> 0
%12 = and i32 %11, 31 -> 0
%13 = shl nuw i32 1, %12 -> 1
ret i32 %13 -> 1
}
```
Looks like it is a codegen bug in ARM backend.
https://github.com/llvm/llvm-project/pull/100899
More information about the llvm-commits
mailing list