Issue |
139641
|
Summary |
Missed Optimization: -(x & c1) >> shamt | -(x & c1) —> x & c1 ? -1 : 0 when 2^shamt > c1 and shamt ≤ bitwidth(x)/2
|
Labels |
new issue
|
Assignees |
|
Reporter |
Cancelll
|
```llvm
define i64 @src(i32 %arg0) {
%1 = sub i32 0, %arg0
%2 = and i32 %1, 63
%3 = zext nneg i32 %2 to i64
%4 = sub nsw i64 0, %3
%5 = lshr i64 %4, 8
%6 = or i64 %5, %4
ret i64 %6
}
define i64 @tgt(i32 %arg0) {
%1 = and i32 %arg0, 63
%2 = icmp ne i32 %1, 0
%3 = sext i1 %2 to i64
ret i64 %3
}
```
Alive2: [https://alive2.llvm.org/ce/z/yLQgJp](https://alive2.llvm.org/ce/z/LqeBrj)
Example: [https://godbolt.org/z/hEKWGoeq3](https://godbolt.org/z/7KxvbWbq3)
Found this pattern in function bn_rshift_fixed_top in openssl/crypto/bn/sn_shift.c
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs