News for hackers. Stuff that matters.
Re:How to check if any word is zero by poorlyknit on Thursday October 20, 2022 @03:25PM (#33279423)
In a similar vein you could turn

  a == 0 || b == 0 || c == 0
into

  !(a && b && c).
If we don't need short-circuit evaluation of b == 0 and c == 0 (which the article assumes), we can turn this into

  !(a & b & c)
which yields similar assembly (n + 1 instructions without branches):

  R0 <- and Ra Rb
  R1 <- and R0 Rc
  R2 <- not R1
Would make an interesting benchmark.
Re:How to check if any word is zero by leni536 on Thursday October 20, 2022 @03:35PM (#33279570)
!(a & b & c) is not equivalent to !(a && b && c) for int values of a b and c.
Re:How to check if any word is zero by shaggie76 on Thursday October 20, 2022 @03:36PM (#33279605)
I think a = 1, b = 2 would mean !(a & b) = true implying one of them is zero?
Re:How to check if any word is zero by pklausler on Thursday October 20, 2022 @03:36PM (#33279601)
Good lord, no, that doesn't work. Try it with a=1, b=2, c=4.