Open Validark opened 3 weeks ago
@llvm/issue-subscribers-backend-x86
Author: Niles Salter (Validark)
I've tagged this as x86 but hopefully we can handle this generically
@RKSimon just noticed you self-assigned this, but I took a stab at this last night. This is the PR #109215 .
Zig code:
Compiled for Znver3:
I expected it to be
and
+andn
+andn
+andn
for the scalar version, andvpand
+vpandn
+vpandn
+vpandn
for the vector version. However, it turnss &= ~(z & ~y);
intos &= ~z | y;
. While this makes sense on machines withoutandn
(and doesn't matter for machines which haveandn
andorn
, or justvpternlogq
), with x86-64 BMI1 we only getandn
. We never got anorn
, so this optimization hurts us.LLVM (optimized):
LLVM Godbolt link