[PATCH] D126638: [CGP] Also freeze ctlz/cttz operand when despeculating
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 9 02:22:19 PDT 2022
nikic added a comment.
In D126638#3566645 <https://reviews.llvm.org/D126638#3566645>, @spatel wrote:
> https://alive2.llvm.org/ce/z/iwd4ba
> This is needed for correctness, so LGTM.
>
> It might be good to add tests for other targets. I didn't step through this to see why, but the code for AArch and ARM actually looks better when we re-use the frozen value.
>
> rbit w9, w0
> mov w8, #32
> clz w9, w9
> cmp w0, #0
> csel w0, w8, w9, eq
>
> vs.
>
> rbit w8, w0
> clz w0, w8
For what input is that? As far as I can tell, AArch64 never uses despeculation, and ARM uses a libcall legalization where it makes no difference. I'm trying this one:
define i32 @ctlz_i32(i32 %a) nounwind {
%r = call i32 @llvm.ctlz.i32(i32 %a, i1 false)
ret i32 %r
}
declare i32 @llvm.ctlz.i32(i32, i1)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126638/new/
https://reviews.llvm.org/D126638
More information about the llvm-commits
mailing list