News for hackers. Stuff that matters.
Re:Bend: a high-level language that runs on GPUs (via HVM2) by nneonneo on Friday May 17, 2024 @02:24PM (#40392824)
You might want to double check with objdump if the loop is actually vectorized, or if the compiler just optimizes it out. Your loop actually performs signed integer overflow, which is UB in C++; the compiler could legally output anything. If you want to avoid the UB, declare sum as unsigned (unsigned integer overflow is well-defined); the optimization will still happen but at least you’ll be guaranteed that it’ll be correct.
Re:Bend: a high-level language that runs on GPUs (via HVM2) by ziedaniel1 on Friday May 17, 2024 @03:04PM (#40393228)
I did make sure to check before posting.

Good point about the signed integer overflow, though!