[llvm] [DemandedBits] Track demanded bits for clmul instrinsics (PR #202415)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 4 10:16:17 PDT 2026
dtcxzyw wrote:
The clmul support is available now (see https://github.com/AliveToolkit/alive2/pull/1318). But it hasn't been deployed to alive2.llvm.org.
```
; ./alive-tv --disable-undef-input test.ll
define i8 @src(i8 %x, i8 %y, i8 range(i8 1, 0) %demanded) {
%clmul = call i8 @llvm.clmul.i8(i8 %x, i8 %y)
%masked = and i8 %clmul, %demanded
ret i8 %masked
}
define i8 @tgt(i8 %x, i8 %y, i8 %demanded) {
%lz = call i8 @llvm.ctlz.i8(i8 %demanded, i1 true)
%mask = lshr i8 -1, %lz
%masked_x = and i8 %x, %mask
%masked_y = and i8 %y, %mask
%clmul = call i8 @llvm.clmul.i8(i8 %masked_x, i8 %masked_y)
%masked = and i8 %clmul, %demanded
ret i8 %masked
}
```
```
----------------------------------------
define i8 @src(i8 %x, i8 %y, i8 %demanded) {
init:
%#range_0_%demanded = !range i8 %demanded, i8 1, i8 0
br label %#0
#0:
%clmul = clmul i8 %x, %y
%masked = and i8 %clmul, %#range_0_%demanded
ret i8 %masked
}
=>
define i8 @tgt(i8 %x, i8 %y, i8 %demanded) {
#0:
%lz = ctlz i8 %demanded, 1
%mask = lshr i8 255, %lz
%masked_x = and i8 %x, %mask
%masked_y = and i8 %y, %mask
%clmul = clmul i8 %masked_x, %masked_y
%masked = and i8 %clmul, %demanded
ret i8 %masked
}
Transformation seems to be correct!
```
https://github.com/llvm/llvm-project/pull/202415
More information about the llvm-commits
mailing list