https://bugs.llvm.org/show_bug.cgi?id=41647
Bug ID: 41647
Summary: does not eliminate a branch on shifts
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedb...@nondot.org
Reporter: sland...@gmail.com
CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org
When creating a mask, with unsigned n (I'm doing this in Zig because underflow
is undefined in Zig)
if (n == 0) {
return 0;
} else {
return u64(math.maxInt(u64)) >> @intCast(u6, ((64 - @intCast(u7, n))));
}
mask:
test dil, dil
je .LBB0_1
neg dil
mov rax, -1
shrx rax, rax, rdi
ret
.LBB0_1:
xor eax, eax
ret
But the branch is unneeded.
https://www.felixcloutier.com/x86/sarx:shlx:shrx
If the value specified in the first source operand exceeds OperandSize -1, the
COUNT value is masked.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs