1947532161734599029, 1954386590249472032, 1949180928623845610

This commit is contained in:
ed committed 2026-08-25 17:55:24 -04:00
1 parent 9bbd485e60
commit b658b0b786
78 files changed
+2948

No files matched your search

@@ -0,0 +1,51 @@
---
title: "@NOTimothyLottes Real-time PT is the future (present in many games already) and I think NV would have the advantage in the Tflop/s/$ over AMD in PT performance."
type: archive
source: twitter
source_url: "https://x.com/RouaniJihad/status/1954499162906464460"
author: "🕹️G🅰MESTUFFS🎮"
handle: RouaniJihad
post_id: "1954499162906464460"
date: 2025-08-10
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- NOTimothyLottes
description: "@NOTimothyLottes Real-time PT is the future (present in many games already) and I think NV would have the advantage in the Tflop/s/$ over AMD in PT performance."
in_reply_to: ""
parent_post_id: "1954386590249472032"
---
## Source
- URL: https://x.com/RouaniJihad/status/1954499162906464460
- Author: 🕹️G🅰MESTUFFS🎮 (@RouaniJihad)
- Posted: 2025-08-10 11:04:47
## Branch
**1/** **@RouaniJihad** ^1954499162906464460
**@NOTimothyLottes**
Real-time PT is the future (present in many games already) and I think NV would have the advantage in the Tflop/s/$ over AMD in PT performance.
NV is at the driver's seat, so the future is whatever they decide, and right now seems like they want to push NTC and Neural Materials.
**2/** **@NOTimothyLottes** ^1954572872992616905
**@RouaniJihad**
'Real-time PT is the future' = gamers taking out loans for their HW. NV won't be selling HW for under cost, they have no service/subscription to shift costs to.
**3/** **@RouaniJihad** ^1954576999353061467
**@NOTimothyLottes**
That is sadly true, I don't see a world where GPUs will get cheaper than what they are today (which is already expensive), especially with TSMC charging more and more per each node advancement
## Related
- Spine: [[archive/threads/NOTimothyLottes/2025-08-10-we-are-in-era-of-scaling-by-now]]
@@ -0,0 +1,37 @@
---
title: "@NOTimothyLottes Yeah."
type: archive
source: twitter
source_url: "https://x.com/SebAaltonen/status/1954475503395492190"
author: "Sebastian Aaltonen"
handle: SebAaltonen
post_id: "1954475503395492190"
date: 2025-08-10
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- NOTimothyLottes
description: "@NOTimothyLottes Yeah."
in_reply_to: ""
parent_post_id: "1954390804480328148"
---
## Source
- URL: https://x.com/SebAaltonen/status/1954475503395492190
- Author: Sebastian Aaltonen (@SebAaltonen)
- Posted: 2025-08-10 09:30:47
## Branch
**1/** **@SebAaltonen** ^1954475503395492190
**@NOTimothyLottes**
Yeah. Top end PC GPU is nowadays 2500€ and PS5 Pro is 850€. That's over 2x price compared to 2 generations ago. If the price increases continue like this, nobody can afford AAA gaming anymore.
## Related
- Spine: [[archive/threads/NOTimothyLottes/2025-08-10-we-are-in-era-of-scaling-by-now]]
@@ -0,0 +1,37 @@
---
title: "@NOTimothyLottes Me trying to figure out if you're talking about cash or cache..."
type: archive
source: twitter
source_url: "https://x.com/StefDevs/status/1954551051136254313"
author: "StefDevs"
handle: StefDevs
post_id: "1954551051136254313"
date: 2025-08-10
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- NOTimothyLottes
description: "@NOTimothyLottes Me trying to figure out if you're talking about cash or cache..."
in_reply_to: ""
parent_post_id: "1954386590249472032"
---
## Source
- URL: https://x.com/StefDevs/status/1954551051136254313
- Author: StefDevs (@StefDevs)
- Posted: 2025-08-10 14:30:59
## Branch
**1/** **@StefDevs** ^1954551051136254313
**@NOTimothyLottes**
Me trying to figure out if you're talking about cash or cache...
## Related
- Spine: [[archive/threads/NOTimothyLottes/2025-08-10-we-are-in-era-of-scaling-by-now]]
@@ -0,0 +1,43 @@
---
title: "@NOTimothyLottes Are the cost numbers adjusted for inflation?"
type: archive
source: twitter
source_url: "https://x.com/bboyBladeJ/status/1954392275527569793"
author: "Juraj Obert"
handle: bboyBladeJ
post_id: "1954392275527569793"
date: 2025-08-10
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- NOTimothyLottes
description: "@NOTimothyLottes Are the cost numbers adjusted for inflation?"
in_reply_to: ""
parent_post_id: "1954386590249472032"
---
## Source
- URL: https://x.com/bboyBladeJ/status/1954392275527569793
- Author: Juraj Obert (@bboyBladeJ)
- Posted: 2025-08-10 04:00:03
## Branch
**1/** **@bboyBladeJ** ^1954392275527569793
**@NOTimothyLottes**
Are the cost numbers adjusted for inflation?
**2/** **@NOTimothyLottes** ^1954393337701515324
**@bboyBladeJ**
Smart question. Not inflation adjusted. But I'd argue the normalization factor might be better as scaling by disposable income (or say entertainment budget).
## Related
- Spine: [[archive/threads/NOTimothyLottes/2025-08-10-we-are-in-era-of-scaling-by-now]]
@@ -0,0 +1,55 @@
---
title: "@NOTimothyLottes I mean, on the Nvidia side you can clearly see the improvement this gen in Gb/s/$, and you're not even adjusting with inflation which is quite unfair."
type: archive
source: twitter
source_url: "https://x.com/beyond_fps/status/1954488936920928689"
author: "Beyond FPS"
handle: beyond_fps
post_id: "1954488936920928689"
date: 2025-08-10
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- NOTimothyLottes
description: "@NOTimothyLottes I mean, on the Nvidia side you can clearly see the improvement this gen in Gb/s/$, and you're not even adjusting with inflation which is quite unfair."
in_reply_to: ""
parent_post_id: "1954386590249472032"
---
## Source
- URL: https://x.com/beyond_fps/status/1954488936920928689
- Author: Beyond FPS (@beyond_fps)
- Posted: 2025-08-10 10:24:09
## Branch
**1/** **@beyond_fps** ^1954488936920928689
**@NOTimothyLottes**
I mean, on the Nvidia side you can clearly see the improvement this gen in Gb/s/$, and you're not even adjusting with inflation which is quite unfair.
**2/** **@NOTimothyLottes** ^1954571552483074211
**@beyond_fps**
Lets be frank, the best in the table is AMD in 2017 with the 570 at 1.318 Gb/s/$ where AMD was aggressively digging into margins to get market share. NVIDIA shows the higher margin options. But that's not really 'scaling', rather it's flat mixed with card pricing volatility.
**3/** **@beyond_fps** ^1954573818640417230
**@NOTimothyLottes**
Yes, with 2017's money. With 2025's money, that RX 570 is roughly 1 GB/s/$ (170 --> 224$) vs 1.22 from the 5070.
**4/** **@beyond_fps** ^1954574640963084472
**@NOTimothyLottes**
Also the amount of GB is rather dictated by consoles IMO. If games are made with 16GB max in mind (and that's whole system memory, realistically it's 10-12) doesn't really make much sense to have much higher quantities of VRAM. Talking about consumer products at least.
## Related
- Spine: [[archive/threads/NOTimothyLottes/2025-08-10-we-are-in-era-of-scaling-by-now]]
@@ -0,0 +1,48 @@
---
title: "We are in era of \"scaling by $\" now."
type: archive
source: twitter
source_url: "https://x.com/NOTimothyLottes/status/1954386590249472032"
author: "NOTimothyLottes"
handle: NOTimothyLottes
post_id: "1954386590249472032"
date: 2025-08-10
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- NOTimothyLottes
description: "We are in era of \"scaling by $\" now."
in_reply_to: ""
---
## Source
- URL: https://x.com/NOTimothyLottes/status/1954386590249472032
- Author: NOTimothyLottes (@NOTimothyLottes)
- Posted: 2025-08-10 03:37:28
## Thread
**1/** **@NOTimothyLottes** ^1954386590249472032
We are in era of "scaling by $" now. Meaning no scaling of perf/$. The ORANGE is when vendors inflated peaks by dual issuing 32-bit FMAs. But it's the GB/s/$ and GB/$ stagnation that deserves more thought ...
![](https://pbs.twimg.com/media/Gx9fGQOXcAAatcm?format=png&name=orig)
Branches: [[archive/threads/NOTimothyLottes/2025-08-10-we-are-in-era-of-scaling-by-now/2025-08-10-bboyBladeJ-are-the-cost-numbers-adjusted-for-inflation]], [[archive/threads/NOTimothyLottes/2025-08-10-we-are-in-era-of-scaling-by-now/2025-08-10-beyond_fps-i-mean-on-the-nvidia-side-you-can-clearly-see-the]], [[archive/threads/NOTimothyLottes/2025-08-10-we-are-in-era-of-scaling-by-now/2025-08-10-RouaniJihad-real-time-pt-is-the-future-present-in-many-games]], [[archive/threads/NOTimothyLottes/2025-08-10-we-are-in-era-of-scaling-by-now/2025-08-10-StefDevs-me-trying-to-figure-out-if-youre-talking-about]]
**2/** **@NOTimothyLottes** ^1954388033501082046
Lots of folks like to claim that real-time path tracing and giant ML networks are the future. And I ask, how exactly are those technologies reducing bandwidth/frame or vram/game? Long time now, no MEM stats/$ scaling ...
![](https://pbs.twimg.com/media/Gx9gqocWYAAhMlf?format=png&name=orig)
**3/** **@NOTimothyLottes** ^1954390804480328148
We are past the {power,thermal,process} walls, we are dealing with the final {wallet} wall. Where ratcheting up hardware minspec, simply permanently increases the gamer's baseline hardware costs ... no future process !/$ scaling is coming to save anyone {devs,gamers, or vendors}
![](https://pbs.twimg.com/media/Gx9hm8GXAAAl9mb?format=png&name=orig)
Branches: [[archive/threads/NOTimothyLottes/2025-08-10-we-are-in-era-of-scaling-by-now/2025-08-10-SebAaltonen-yeah-top-end-pc-gpu-is-nowadays-2500-and-ps5-pro]]
+1
View File
@@ -54,6 +54,7 @@ tags:
- [[archive/threads/NOTimothyLottes/2025-07-31-been-on-the-fence-on-writing-shader-interfaces-in]]
- [[archive/threads/NOTimothyLottes/2025-07-31-people-claim-assembly-is-hard]]
- [[archive/threads/NOTimothyLottes/2025-08-01-at-least-for-my-next-at-home-project-i-think-the]]
- [[archive/threads/NOTimothyLottes/2025-08-10-we-are-in-era-of-scaling-by-now]]
- [[archive/threads/NOTimothyLottes/2025-09-03-re-john-dark1x-and-https-youtu-be-uxqumm5aka8-si]]
- [[archive/threads/NOTimothyLottes/2025-10-10-thread-about-this-from-rfleury-https-www-rfleury]]
- [[archive/threads/NOTimothyLottes/2025-10-13-short-talk-on-how-i-do-cpu-side-debugging-without]]
@@ -0,0 +1,38 @@
---
title: "i've developed some techniques to eliminate tables while remaining branch-free."
type: archive
source: twitter
source_url: "https://x.com/VPCOMPRESSB/status/1947532161734599029"
author: "/i:'mɪər/"
handle: VPCOMPRESSB
post_id: "1947532161734599029"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- VPCOMPRESSB
description: "i've developed some techniques to eliminate tables while remaining branch-free."
in_reply_to: ""
---
## Source
- URL: https://x.com/VPCOMPRESSB/status/1947532161734599029
- Author: /i:'mɪər/ (@VPCOMPRESSB)
- Posted: 2025-07-22 05:40:25
## Thread
**1/** **@VPCOMPRESSB** ^1947532161734599029
i've developed some techniques to eliminate tables while remaining branch-free.
the techniques are applicable to strings thus far for manipulation and detection.
**2/** **@VPCOMPRESSB** ^1947532164029157680
note that, to understand this type of code, i suggest not reading. instead, visualize what the input and output looks like, and why they look like that. essentially, imagine A transforming into B.
https://gist.github.com/VPCOMPRESSB/ad87c2a4df0273a1f0c475a31c1f21a5
+1
View File
@@ -9,5 +9,6 @@ tags:
- VPCOMPRESSB
---
- [[archive/threads/VPCOMPRESSB/2025-07-22-ive-developed-some-techniques-to-eliminate-tables]]
- [[archive/threads/VPCOMPRESSB/2025-11-10-im-not-familiar-with-your-problem]]
- [[archive/threads/VPCOMPRESSB/2025-11-20-no-tokens-and-no-asts]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain I sometimes use that principle in SQL so there's only one if statement instead of like 10"
type: archive
source: twitter
source_url: "https://x.com/0xE1/status/1947702451144147351"
author: "Anton Kovalenko"
handle: 0xE1
post_id: "1947702451144147351"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain I sometimes use that principle in SQL so there's only one if statement instead of like 10"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/0xE1/status/1947702451144147351
- Author: Anton Kovalenko (@0xE1)
- Posted: 2025-07-22 16:57:05
## Branch
**1/** **@0xE1** ^1947702451144147351
**@nicbarkeragain**
I sometimes use that principle in SQL so there's only one if statement instead of like 10
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,39 @@
---
title: "@nicbarkeragain What would be an actual real life use case?"
type: archive
source: twitter
source_url: "https://x.com/AnshumanKhanna5/status/1947700590953566232"
author: "Anshuman Khanna"
handle: AnshumanKhanna5
post_id: "1947700590953566232"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain What would be an actual real life use case?"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/AnshumanKhanna5/status/1947700590953566232
- Author: Anshuman Khanna (@AnshumanKhanna5)
- Posted: 2025-07-22 16:49:42
## Branch
**1/** **@AnshumanKhanna5** ^1947700590953566232
**@nicbarkeragain**
What would be an actual real life use case?
Because I feel I'll just bloat the program with completely redundant data
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain It’s a beautiful thing but also pointless and unreadable unless in an environment that can’t afford an if statement."
type: archive
source: twitter
source_url: "https://x.com/AstrodogX/status/1947798127311741351"
author: "Agent Mish"
handle: AstrodogX
post_id: "1947798127311741351"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain It’s a beautiful thing but also pointless and unreadable unless in an environment that can’t afford an if statement."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/AstrodogX/status/1947798127311741351
- Author: Agent Mish (@AstrodogX)
- Posted: 2025-07-22 23:17:16
## Branch
**1/** **@AstrodogX** ^1947798127311741351
**@nicbarkeragain**
It’s a beautiful thing but also pointless and unreadable unless in an environment that can’t afford an if statement. There is something beautiful about using bitwise ops to index into an array to O(1) performance though, even if most compilers optimize out the branches.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain I thought this kind of masking was standard regardless of branch clobbering."
type: archive
source: twitter
source_url: "https://x.com/BonesMoses/status/1947722644239094011"
author: "Shaun Thomas"
handle: BonesMoses
post_id: "1947722644239094011"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain I thought this kind of masking was standard regardless of branch clobbering."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/BonesMoses/status/1947722644239094011
- Author: Shaun Thomas (@BonesMoses)
- Posted: 2025-07-22 18:17:19
## Branch
**1/** **@BonesMoses** ^1947722644239094011
**@nicbarkeragain**
I thought this kind of masking was standard regardless of branch clobbering. 🤔
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain Cool."
type: archive
source: twitter
source_url: "https://x.com/DeusIX_imxn/status/1947694653181989124"
author: "DeusIX"
handle: DeusIX_imxn
post_id: "1947694653181989124"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Cool."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/DeusIX_imxn/status/1947694653181989124
- Author: DeusIX (@DeusIX_imxn)
- Posted: 2025-07-22 16:26:06
## Branch
**1/** **@DeusIX_imxn** ^1947694653181989124
**@nicbarkeragain**
Cool. But I prefer to be able to read my code. 😀
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,41 @@
---
title: "@nicbarkeragain It's cool, but unless you unroll the loop fully, it's still branching."
type: archive
source: twitter
source_url: "https://x.com/Epiq_Phale/status/1947780196565696779"
author: "epiq_phale"
handle: Epiq_Phale
post_id: "1947780196565696779"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain It's cool, but unless you unroll the loop fully, it's still branching."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/Epiq_Phale/status/1947780196565696779
- Author: epiq_phale (@Epiq_Phale)
- Posted: 2025-07-22 22:06:01
## Branch
**1/** **@Epiq_Phale** ^1947780196565696779
**@nicbarkeragain**
It's cool, but unless you unroll the loop fully, it's still branching. Checking a loop counter is effectively an if statement.
And if you wanted to squeeze it more, maybe something like
sum += data[i].value & data[i].type
With A = 0 and B = -1
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,39 @@
---
title: "@nicbarkeragain One additional read instead of using the result of \"==\"."
type: archive
source: twitter
source_url: "https://x.com/JustSlavic/status/1947558561539621100"
author: "Sλava"
handle: JustSlavic
post_id: "1947558561539621100"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain One additional read instead of using the result of \"==\"."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/JustSlavic/status/1947558561539621100
- Author: Sλava (@JustSlavic)
- Posted: 2025-07-22 07:25:19
## Branch
**1/** **@JustSlavic** ^1947558561539621100
**@nicbarkeragain**
One additional read instead of using the result of "==".
sum += value * (type == TYPE_B);
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,39 @@
---
title: "@nicbarkeragain of course, it's important to be careful."
type: archive
source: twitter
source_url: "https://x.com/Random832/status/1947760489569661186"
author: "Random832"
handle: Random832
post_id: "1947760489569661186"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain of course, it's important to be careful."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/Random832/status/1947760489569661186
- Author: Random832 (@Random832)
- Posted: 2025-07-22 20:47:43
## Branch
**1/** **@Random832** ^1947760489569661186
**@nicbarkeragain**
of course, it's important to be careful.
on modern architectures, something you might think is a branch may be a conditional assignment that is much cheaper, and some of these techniques instead introduce dependencies and slow down pipelines.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,38 @@
---
title: "@nicbarkeragain ```[<int>] = <val>```"
type: archive
source: twitter
source_url: "https://x.com/RaykiruS/status/1947663637209911694"
author: "雷琪如"
handle: RaykiruS
post_id: "1947663637209911694"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain ```[<int>] = <val>```"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/RaykiruS/status/1947663637209911694
- Author: 雷琪如 (@RaykiruS)
- Posted: 2025-07-22 14:22:51
## Branch
**1/** **@RaykiruS** ^1947663637209911694
**@nicbarkeragain**
```[<int>] = <val>```
this is valid syntax??? c is wild with the way it works sometimes
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,39 @@
---
title: "@nicbarkeragain That's cool, but also compilers know how to do it as well, sometimes the assembly it generates when it spots a branchless version by itself is better then the one generated by compiling your implementation."
type: archive
source: twitter
source_url: "https://x.com/RaykiruS/status/1947664810306638004"
author: "雷琪如"
handle: RaykiruS
post_id: "1947664810306638004"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain That's cool, but also compilers know how to do it as well, sometimes the assembly it generates when it spots a branchless version by itself is better then the one generated by compiling your implementation."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/RaykiruS/status/1947664810306638004
- Author: 雷琪如 (@RaykiruS)
- Posted: 2025-07-22 14:27:31
## Branch
**1/** **@RaykiruS** ^1947664810306638004
**@nicbarkeragain**
That's cool, but also compilers know how to do it as well, sometimes the assembly it generates when it spots a branchless version by itself is better then the one generated by compiling your implementation.
In any case, if someone wants optimization they should measure first
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,39 @@
---
title: "@nicbarkeragain I don't think you even need a multiplication."
type: archive
source: twitter
source_url: "https://x.com/RepealTCPA1947/status/1947746349933289559"
author: "Workhouse Overseer 🌐🥑🍌"
handle: RepealTCPA1947
post_id: "1947746349933289559"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain I don't think you even need a multiplication."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/RepealTCPA1947/status/1947746349933289559
- Author: Workhouse Overseer 🌐🥑🍌 (@RepealTCPA1947)
- Posted: 2025-07-22 19:51:31
## Branch
**1/** **@RepealTCPA1947** ^1947746349933289559
**@nicbarkeragain**
I don't think you even need a multiplication. Just a ternary should be enough:
`sum += data.type == B ? data.value : 0`
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain What colour scheme is that btw?"
type: archive
source: twitter
source_url: "https://x.com/RepealTCPA1947/status/1947746612815499754"
author: "Workhouse Overseer 🌐🥑🍌"
handle: RepealTCPA1947
post_id: "1947746612815499754"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain What colour scheme is that btw?"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/RepealTCPA1947/status/1947746612815499754
- Author: Workhouse Overseer 🌐🥑🍌 (@RepealTCPA1947)
- Posted: 2025-07-22 19:52:34
## Branch
**1/** **@RepealTCPA1947** ^1947746612815499754
**@nicbarkeragain**
What colour scheme is that btw?
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain If you are doing a for loop you are still branching"
type: archive
source: twitter
source_url: "https://x.com/RoseSilicon/status/1947632017538957794"
author: "Sei K."
handle: RoseSilicon
post_id: "1947632017538957794"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain If you are doing a for loop you are still branching"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/RoseSilicon/status/1947632017538957794
- Author: Sei K. (@RoseSilicon)
- Posted: 2025-07-22 12:17:12
## Branch
**1/** **@RoseSilicon** ^1947632017538957794
**@nicbarkeragain**
If you are doing a for loop you are still branching
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,46 @@
---
title: "A really long time ago, programming a simple game in basic on a 6502 based Commodore PET, I changed the logic from:"
type: archive
source: twitter
source_url: "https://x.com/RussellPolo/status/1947564413780680847"
author: "Russell Polo"
handle: RussellPolo
post_id: "1947564413780680847"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "A really long time ago, programming a simple game in basic on a 6502 based Commodore PET, I changed the logic from:"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/RussellPolo/status/1947564413780680847
- Author: Russell Polo (@RussellPolo)
- Posted: 2025-07-22 07:48:34
## Branch
**1/** **@RussellPolo** ^1947564413780680847
A really long time ago, programming a simple game in basic on a 6502 based Commodore PET, I changed the logic from:
If <leftarrow> then pos=pos-1
If <rightarrow> then pos=pos+1
If...
To:
pos=pos+key2motion[keypress]
The result was a dramatic improvement. Sluggish character movement became smooth, quick motion. The result wasn't as easy to understand, but the performance result more than justified the confusing code.
Ever since, I've always looked for ways to avoid branching logic. These are the types of optimizations you could never expect from a compiler.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,41 @@
---
title: "@nicbarkeragain Why should you do something that your compiler do for you?"
type: archive
source: twitter
source_url: "https://x.com/SMrrandom/status/1947619611249189208"
author: "Born Lucky"
handle: SMrrandom
post_id: "1947619611249189208"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Why should you do something that your compiler do for you?"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/SMrrandom/status/1947619611249189208
- Author: Born Lucky (@SMrrandom)
- Posted: 2025-07-22 11:27:55
## Branch
**1/** **@SMrrandom** ^1947619611249189208
**@nicbarkeragain**
Why should you do something that your compiler do for you?
I think the most performant programming style is writing bytecode or assembler.
Today 80% of projects are not suffering because of performance. Its because of scalability and readability
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain Why can't compilers implement this optimization themselves? At least in this example, it seems like a fairly mechanical transformation"
type: archive
source: twitter
source_url: "https://x.com/StatisticsFTW/status/1947684921155199371"
author: "Robert Balicki (👀 @IsographLabs)"
handle: StatisticsFTW
post_id: "1947684921155199371"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Why can't compilers implement this optimization themselves? At least in this example, it seems like a fairly mechanical transformation"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/StatisticsFTW/status/1947684921155199371
- Author: Robert Balicki (👀 @IsographLabs) (@StatisticsFTW)
- Posted: 2025-07-22 15:47:26
## Branch
**1/** **@StatisticsFTW** ^1947684921155199371
**@nicbarkeragain**
Why can't compilers implement this optimization themselves? At least in this example, it seems like a fairly mechanical transformation
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,39 @@
---
title: "i'm branch-free by default."
type: archive
source: twitter
source_url: "https://x.com/VPCOMPRESSB/status/1947536641876242555"
author: "/i:'mɪər/"
handle: VPCOMPRESSB
post_id: "1947536641876242555"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "i'm branch-free by default."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/VPCOMPRESSB/status/1947536641876242555
- Author: /i:'mɪər/ (@VPCOMPRESSB)
- Posted: 2025-07-22 05:58:13
## Branch
**1/** **@VPCOMPRESSB** ^1947536641876242555
i'm branch-free by default. it's not for conventional optimizations (e.g. optimizing for time), but to maintain a minimum code depth / reduce complexity.
my paradigm also dislikes branches. i only want A->B, and not A->{B|C|D}. essentially, the more possibilities A can transform into -> more branches -> more complex.
https://x.com/VPCOMPRESSB/status/1947532161734599029
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,38 @@
---
title: "@nicbarkeragain Wait I am cooked."
type: archive
source: twitter
source_url: "https://x.com/XylnZ/status/1947604029724627329"
author: "明日の負担"
handle: XylnZ
post_id: "1947604029724627329"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Wait I am cooked."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/XylnZ/status/1947604029724627329
- Author: 明日の負担 (@XylnZ)
- Posted: 2025-07-22 10:26:00
## Branch
**1/** **@XylnZ** ^1947604029724627329
**@nicbarkeragain**
Wait I am cooked. Are you trolling or serious?
It must be a troll, right? Web developers aren't that stupid right?
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain I think it's a cool field, like only using stack memory (e.g."
type: archive
source: twitter
source_url: "https://x.com/_benwick/status/1947680044093997065"
author: "Benwick"
handle: _benwick
post_id: "1947680044093997065"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain I think it's a cool field, like only using stack memory (e.g."
in_reply_to: ""
parent_post_id: "1947506506922098959"
---
## Source
- URL: https://x.com/_benwick/status/1947680044093997065
- Author: Benwick (@_benwick)
- Posted: 2025-07-22 15:28:03
## Branch
**1/** **@_benwick** ^1947680044093997065
**@nicbarkeragain**
I think it's a cool field, like only using stack memory (e.g. alloca()), but people should be cautioned that "eliminating branches at all cost" isn't always the solution. They're terrible on shaders and bad in tight loops, but not something inherently evil.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain It's good inside hot loops and shaders."
type: archive
source: twitter
source_url: "https://x.com/_benwick/status/1947678617091068140"
author: "Benwick"
handle: _benwick
post_id: "1947678617091068140"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain It's good inside hot loops and shaders."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/_benwick/status/1947678617091068140
- Author: Benwick (@_benwick)
- Posted: 2025-07-22 15:22:23
## Branch
**1/** **@_benwick** ^1947678617091068140
**@nicbarkeragain**
It's good inside hot loops and shaders. But it's not a cure all. Branch-prediction in large codebases means a CPU can ignore entire sections of nested if statements without testing every single one every time.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,67 @@
---
title: "@nicbarkeragain A more compact example is using a bitmask integer."
type: archive
source: twitter
source_url: "https://x.com/anicic_filip/status/1947536063959839200"
author: "Filip Aničić"
handle: anicic_filip
post_id: "1947536063959839200"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain A more compact example is using a bitmask integer."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/anicic_filip/status/1947536063959839200
- Author: Filip Aničić (@anicic_filip)
- Posted: 2025-07-22 05:55:55
## Branch
**1/** **@anicic_filip** ^1947536063959839200
**@nicbarkeragain**
A more compact example is using a bitmask integer. It's a good way to learn bitshifting and you don't need to update the look up table when you update the enum
![](https://pbs.twimg.com/media/GwcJPSnWgAM_y5U?format=png&name=orig)
**2/** **@nicbarkeragain** ^1947536361520828795
**@anicic_filip**
Agreed, I made the assumption that people who haven’t heard of branchless before might struggle a little with the more compact approaches 🙂
**3/** **@anicic_filip** ^1947538090689528008
**@nicbarkeragain**
Look up table is a good introductory example.
The logic of CPUs doing multiplications faster than boolean comparisons is bonkers.
Is it releated to SIMD compiler optimizations or does this apply to non-AVX supporting CPUs?
**4/** **@Ashkan_GC** ^1947554067011838054
**@anicic_filip** **@nicbarkeragain**
Branches are slower because they need to be predicted and predictions can be wrong and cause stalls in instruction processing
**5/** **@anicic_filip** ^1947565036106313960
**@Ashkan_GC** **@nicbarkeragain**
So the CPU having to switch between doing a sum or not doing a sum based on the if is slowing it down, while doing a constant workload of multiply and then sum is more predictable, so also faster?
Does this mean that older CPUs with worse to none prediction would suffer the most?
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain It's also a key component in developing good implementations of cryptography to prevent side channel and timing attacks."
type: archive
source: twitter
source_url: "https://x.com/augeeidos/status/1947551685498310729"
author: "Hiro Protagonist (至大)"
handle: augeeidos
post_id: "1947551685498310729"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain It's also a key component in developing good implementations of cryptography to prevent side channel and timing attacks."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/augeeidos/status/1947551685498310729
- Author: Hiro Protagonist (至大) (@augeeidos)
- Posted: 2025-07-22 06:58:00
## Branch
**1/** **@augeeidos** ^1947551685498310729
**@nicbarkeragain**
It's also a key component in developing good implementations of cryptography to prevent side channel and timing attacks.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain Shouldn't a good optimizer already do this?"
type: archive
source: twitter
source_url: "https://x.com/awwscript/status/1947777532214018406"
author: "Austin_Wright"
handle: awwscript
post_id: "1947777532214018406"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Shouldn't a good optimizer already do this?"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/awwscript/status/1947777532214018406
- Author: Austin_Wright (@awwscript)
- Posted: 2025-07-22 21:55:26
## Branch
**1/** **@awwscript** ^1947777532214018406
**@nicbarkeragain**
Shouldn't a good optimizer already do this?
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain It's funny when some people say \"Branches are essentially free these days\" Yeah, not so much :)"
type: archive
source: twitter
source_url: "https://x.com/daniel_collin/status/1947589806395167138"
author: "Daniel Collin"
handle: daniel_collin
post_id: "1947589806395167138"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain It's funny when some people say \"Branches are essentially free these days\" Yeah, not so much :)"
in_reply_to: ""
parent_post_id: "1947506506922098959"
---
## Source
- URL: https://x.com/daniel_collin/status/1947589806395167138
- Author: Daniel Collin (@daniel_collin)
- Posted: 2025-07-22 09:29:28
## Branch
**1/** **@daniel_collin** ^1947589806395167138
**@nicbarkeragain**
It's funny when some people say "Branches are essentially free these days" Yeah, not so much :)
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,41 @@
---
title: "@nicbarkeragain Godbolt example of branchless vs branchfull if-statement"
type: archive
source: twitter
source_url: "https://x.com/eigen_spectra/status/1947674338108309696"
author: "eigenspectra (in SF, let's meet up!)"
handle: eigen_spectra
post_id: "1947674338108309696"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Godbolt example of branchless vs branchfull if-statement"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/eigen_spectra/status/1947674338108309696
- Author: eigenspectra (in SF, let's meet up!) (@eigen_spectra)
- Posted: 2025-07-22 15:05:22
## Branch
**1/** **@eigen_spectra** ^1947674338108309696
**@nicbarkeragain**
Godbolt example of branchless vs branchfull if-statement
https://godbolt.org/z/8166x3q4v
![](https://pbs.twimg.com/media/GweHXJdXgAADUkH?format=jpg&name=orig)
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain That's cool."
type: archive
source: twitter
source_url: "https://x.com/etozheya42/status/1947587396515529052"
author: "Hello"
handle: etozheya42
post_id: "1947587396515529052"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain That's cool."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/etozheya42/status/1947587396515529052
- Author: Hello (@etozheya42)
- Posted: 2025-07-22 09:19:54
## Branch
**1/** **@etozheya42** ^1947587396515529052
**@nicbarkeragain**
That's cool.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain So..."
type: archive
source: twitter
source_url: "https://x.com/feliperybas/status/1947629486259769524"
author: "Rybones"
handle: feliperybas
post_id: "1947629486259769524"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain So..."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/feliperybas/status/1947629486259769524
- Author: Rybones (@feliperybas)
- Posted: 2025-07-22 12:07:09
## Branch
**1/** **@feliperybas** ^1947629486259769524
**@nicbarkeragain**
So... Programming by Object literals?
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,38 @@
---
title: "@nicbarkeragain Looks pretty useless to me in this case."
type: archive
source: twitter
source_url: "https://x.com/gonenb/status/1947550095529881742"
author: "Gonen Beneish"
handle: gonenb
post_id: "1947550095529881742"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Looks pretty useless to me in this case."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/gonenb/status/1947550095529881742
- Author: Gonen Beneish (@gonenb)
- Posted: 2025-07-22 06:51:41
## Branch
**1/** **@gonenb** ^1947550095529881742
**@nicbarkeragain**
Looks pretty useless to me in this case.
If you want speed, sort you data first, then go over only the data you need without any if
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,41 @@
---
title: "@nicbarkeragain Here is a real-life example (excuse my French):"
type: archive
source: twitter
source_url: "https://x.com/illwieckz/status/1947788687820853397"
author: "Thomas Debesse ن"
handle: illwieckz
post_id: "1947788687820853397"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Here is a real-life example (excuse my French):"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/illwieckz/status/1947788687820853397
- Author: Thomas Debesse ن (@illwieckz)
- Posted: 2025-07-22 22:39:45
## Branch
**1/** **@illwieckz** ^1947788687820853397
**@nicbarkeragain**
Here is a real-life example (excuse my French):
https://t.co/WLwJnLDQMh
On the left in red, the original C code, on the bottom right in yellow, the rewritten branchless portable C code, on the top right in green, the same in x86 intrinsics. Taken from Dæmon Engine: @UNVofficial
![](https://pbs.twimg.com/media/GXSpOSLXIAA8-bD?format=jpg&name=orig)
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,43 @@
---
title: "@nicbarkeragain Clang failed to recognize it should use a select op in the IR and using a ternary helped."
type: archive
source: twitter
source_url: "https://x.com/jakubtomsu_/status/1947602738478452869"
author: "Jakub Tomšů"
handle: jakubtomsu_
post_id: "1947602738478452869"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Clang failed to recognize it should use a select op in the IR and using a ternary helped."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/jakubtomsu_/status/1947602738478452869
- Author: Jakub Tomšů (@jakubtomsu_)
- Posted: 2025-07-22 10:20:52
## Branch
**1/** **@jakubtomsu_** ^1947602738478452869
**@nicbarkeragain**
Clang failed to recognize it should use a select op in the IR and using a ternary helped. This gets also unrolled and vectorized and it ends up being faster.
GCC seems to always catch this, no idea why is clang being dumb even in a trivial case like this
https://godbolt.org/z/jMqazcenq
![](https://pbs.twimg.com/media/GwdEnC_XgAAlhqI?format=jpg&name=orig)
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain Nice."
type: archive
source: twitter
source_url: "https://x.com/johan_tlb/status/1947597412861940197"
author: "Johan"
handle: johan_tlb
post_id: "1947597412861940197"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Nice."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/johan_tlb/status/1947597412861940197
- Author: Johan (@johan_tlb)
- Posted: 2025-07-22 09:59:42
## Branch
**1/** **@johan_tlb** ^1947597412861940197
**@nicbarkeragain**
Nice. TIL.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain I don't mind a useful if statement but when I see an else I'm ripping that crap out."
type: archive
source: twitter
source_url: "https://x.com/jrswab/status/1947689862787997780"
author: "jrswab"
handle: jrswab
post_id: "1947689862787997780"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain I don't mind a useful if statement but when I see an else I'm ripping that crap out."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/jrswab/status/1947689862787997780
- Author: jrswab (@jrswab)
- Posted: 2025-07-22 16:07:04
## Branch
**1/** **@jrswab** ^1947689862787997780
**@nicbarkeragain**
I don't mind a useful if statement but when I see an else I'm ripping that crap out.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain I have no idea if it improves performance (in the grand scheme of a legacy canvas app) but I use tricks like this when rendering e.g."
type: archive
source: twitter
source_url: "https://x.com/la_ledda/status/1947546109435367608"
author: "Dan Ledda"
handle: la_ledda
post_id: "1947546109435367608"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain I have no idea if it improves performance (in the grand scheme of a legacy canvas app) but I use tricks like this when rendering e.g."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/la_ledda/status/1947546109435367608
- Author: Dan Ledda (@la_ledda)
- Posted: 2025-07-22 06:35:50
## Branch
**1/** **@la_ledda** ^1947546109435367608
**@nicbarkeragain**
I have no idea if it improves performance (in the grand scheme of a legacy canvas app) but I use tricks like this when rendering e.g. things that are mirrored or flipped, having a -1 for many values that are reversed for the different orientation. It's fun!
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain interesting"
type: archive
source: twitter
source_url: "https://x.com/love_police_ok/status/1947735876093595773"
author: "Pastilhas"
handle: love_police_ok
post_id: "1947735876093595773"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain interesting"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/love_police_ok/status/1947735876093595773
- Author: Pastilhas (@love_police_ok)
- Posted: 2025-07-22 19:09:54
## Branch
**1/** **@love_police_ok** ^1947735876093595773
**@nicbarkeragain**
interesting
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,39 @@
---
title: "@nicbarkeragain It can be done by tools like Terser or by compiler if they are really equal"
type: archive
source: twitter
source_url: "https://x.com/m1nd_killer/status/1947757296970305665"
author: "Kamenskikh Dmitriy"
handle: m1nd_killer
post_id: "1947757296970305665"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain It can be done by tools like Terser or by compiler if they are really equal"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/m1nd_killer/status/1947757296970305665
- Author: Kamenskikh Dmitriy (@m1nd_killer)
- Posted: 2025-07-22 20:35:01
## Branch
**1/** **@m1nd_killer** ^1947757296970305665
**@nicbarkeragain**
It can be done by tools like Terser or by compiler if they are really equal
It is better to make code readable and move this optimisations on compile level
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,44 @@
---
title: "@nicbarkeragain Australia represent!"
type: archive
source: twitter
source_url: "https://x.com/macsmol/status/1947565172064981235"
author: "Maciej Smolczewski"
handle: macsmol
post_id: "1947565172064981235"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Australia represent!"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/macsmol/status/1947565172064981235
- Author: Maciej Smolczewski (@macsmol)
- Posted: 2025-07-22 07:51:35
## Branch
**1/** **@macsmol** ^1947565172064981235
**@nicbarkeragain**
Australia represent!
https://www.youtube.com/watch?v=bVJ-mWWL7cE
**2/** **@nicbarkeragain** ^1947577404089897178
**@macsmol**
Creel is a hero, he's done us proud for sure!
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,43 @@
---
title: "@nicbarkeragain You nerd-sniped me to actually try the sth out (the Creel's example) ."
type: archive
source: twitter
source_url: "https://x.com/macsmol/status/1947581158897709558"
author: "Maciej Smolczewski"
handle: macsmol
post_id: "1947581158897709558"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain You nerd-sniped me to actually try the sth out (the Creel's example) ."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/macsmol/status/1947581158897709558
- Author: Maciej Smolczewski (@macsmol)
- Posted: 2025-07-22 08:55:07
## Branch
**1/** **@macsmol** ^1947581158897709558
**@nicbarkeragain**
You nerd-sniped me to actually try the sth out (the Creel's example) . And the result are not so obvious..?
https://godbolt.org/z/E9e1df5ao
Screenshot has my benchmark results.
I guess the takeaway is that you always need to benchmark.
![](https://pbs.twimg.com/media/GwcyKZ0XUAAV2en?format=png&name=orig)
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain You mean functional programming?"
type: archive
source: twitter
source_url: "https://x.com/narator287/status/1947665723419201844"
author: "Bendžamin 🇬🇱"
handle: narator287
post_id: "1947665723419201844"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain You mean functional programming?"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/narator287/status/1947665723419201844
- Author: Bendžamin 🇬🇱 (@narator287)
- Posted: 2025-07-22 14:31:08
## Branch
**1/** **@narator287** ^1947665723419201844
**@nicbarkeragain**
You mean functional programming?
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain What is the measured performance impact?"
type: archive
source: twitter
source_url: "https://x.com/occidensus/status/1947671520022827359"
author: "Wes"
handle: occidensus
post_id: "1947671520022827359"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain What is the measured performance impact?"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/occidensus/status/1947671520022827359
- Author: Wes (@occidensus)
- Posted: 2025-07-22 14:54:11
## Branch
**1/** **@occidensus** ^1947671520022827359
**@nicbarkeragain**
What is the measured performance impact?
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain Is it for performance reasons? I've only seen it in security contexts, e.g."
type: archive
source: twitter
source_url: "https://x.com/osoleve/status/1947664786524700965"
author: "oso"
handle: osoleve
post_id: "1947664786524700965"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Is it for performance reasons? I've only seen it in security contexts, e.g."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/osoleve/status/1947664786524700965
- Author: oso (@osoleve)
- Posted: 2025-07-22 14:27:25
## Branch
**1/** **@osoleve** ^1947664786524700965
**@nicbarkeragain**
Is it for performance reasons? I've only seen it in security contexts, e.g. to eliminate the surface of a timing attack (which is technically a performance loss)
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain 10x better? I thought branch prediction wouldn't have SO much weight, crazy"
type: archive
source: twitter
source_url: "https://x.com/paulopacitti/status/1947608840100348220"
author: "paulopacitti 🌐"
handle: paulopacitti
post_id: "1947608840100348220"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain 10x better? I thought branch prediction wouldn't have SO much weight, crazy"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/paulopacitti/status/1947608840100348220
- Author: paulopacitti 🌐 (@paulopacitti)
- Posted: 2025-07-22 10:45:06
## Branch
**1/** **@paulopacitti** ^1947608840100348220
**@nicbarkeragain**
10x better? I thought branch prediction wouldn't have SO much weight, crazy
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain Aka Erlang, Prolog etc."
type: archive
source: twitter
source_url: "https://x.com/skunk_works777/status/1947681305447043548"
author: "Warren Buffer Overflow ᯅ"
handle: skunk_works777
post_id: "1947681305447043548"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Aka Erlang, Prolog etc."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/skunk_works777/status/1947681305447043548
- Author: Warren Buffer Overflow ᯅ (@skunk_works777)
- Posted: 2025-07-22 15:33:04
## Branch
**1/** **@skunk_works777** ^1947681305447043548
**@nicbarkeragain**
Aka Erlang, Prolog etc.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,43 @@
---
title: "@nicbarkeragain I'd usually use & or >> but same idea"
type: archive
source: twitter
source_url: "https://x.com/sreekotay/status/1947527210669093247"
author: "sree kotay"
handle: sreekotay
post_id: "1947527210669093247"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain I'd usually use & or >> but same idea"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/sreekotay/status/1947527210669093247
- Author: sree kotay (@sreekotay)
- Posted: 2025-07-22 05:20:44
## Branch
**1/** **@sreekotay** ^1947527210669093247
**@nicbarkeragain**
I'd usually use & or >> but same idea
**2/** **@nicbarkeragain** ^1947535278413124004
**@sreekotay**
Yeah there are usually much more compact representations, I didn’t want to get too compact for an educational post though 🙂
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,43 @@
---
title: "@nicbarkeragain It also matters how random the data is."
type: archive
source: twitter
source_url: "https://x.com/stuartcarnie/status/1947566650276123023"
author: "Stuart Carnie"
handle: stuartcarnie
post_id: "1947566650276123023"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain It also matters how random the data is."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/stuartcarnie/status/1947566650276123023
- Author: Stuart Carnie (@stuartcarnie)
- Posted: 2025-07-22 07:57:28
## Branch
**1/** **@stuartcarnie** ^1947566650276123023
**@nicbarkeragain**
It also matters how random the data is. If the branch predictor can identify patterns, the results will be much closer. For example setting the data to `i % 3` results in <3x difference
**2/** **@nicbarkeragain** ^1947584072517357811
**@stuartcarnie**
Yes, the gap will close significantly if the branch predictor is able to do a good job with the data at hand!
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain Gross just use an if."
type: archive
source: twitter
source_url: "https://x.com/sunblaze/status/1947806831776305624"
author: "James Reid-Smith"
handle: sunblaze
post_id: "1947806831776305624"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Gross just use an if."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/sunblaze/status/1947806831776305624
- Author: James Reid-Smith (@sunblaze)
- Posted: 2025-07-22 23:51:51
## Branch
**1/** **@sunblaze** ^1947806831776305624
**@nicbarkeragain**
Gross just use an if. Preferably in a more readable language
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain I’d also maintain state machines are a kind of branchless programming."
type: archive
source: twitter
source_url: "https://x.com/tripvvire/status/1947680160246833388"
author: "V. Virgilio"
handle: tripvvire
post_id: "1947680160246833388"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain I’d also maintain state machines are a kind of branchless programming."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/tripvvire/status/1947680160246833388
- Author: V. Virgilio (@tripvvire)
- Posted: 2025-07-22 15:28:31
## Branch
**1/** **@tripvvire** ^1947680160246833388
**@nicbarkeragain**
I’d also maintain state machines are a kind of branchless programming. They provide run-time modularity.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain Great post! Which Color scheme / font is used in the picture?"
type: archive
source: twitter
source_url: "https://x.com/viertausend1/status/1947548383758938141"
author: "viertausend"
handle: viertausend1
post_id: "1947548383758938141"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Great post! Which Color scheme / font is used in the picture?"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/viertausend1/status/1947548383758938141
- Author: viertausend (@viertausend1)
- Posted: 2025-07-22 06:44:53
## Branch
**1/** **@viertausend1** ^1947548383758938141
**@nicbarkeragain**
Great post! Which Color scheme / font is used in the picture?
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain * 1 if x else 0"
type: archive
source: twitter
source_url: "https://x.com/wcolefranks/status/1947551648168939943"
author: "Cole"
handle: wcolefranks
post_id: "1947551648168939943"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain * 1 if x else 0"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/wcolefranks/status/1947551648168939943
- Author: Cole (@wcolefranks)
- Posted: 2025-07-22 06:57:51
## Branch
**1/** **@wcolefranks** ^1947551648168939943
**@nicbarkeragain**
* 1 if x else 0
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain this will be slower unless your compiler is really bad."
type: archive
source: twitter
source_url: "https://x.com/weirdcuttlefish/status/1947648138099232971"
author: "Drew"
handle: weirdcuttlefish
post_id: "1947648138099232971"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain this will be slower unless your compiler is really bad."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/weirdcuttlefish/status/1947648138099232971
- Author: Drew (@weirdcuttlefish)
- Posted: 2025-07-22 13:21:16
## Branch
**1/** **@weirdcuttlefish** ^1947648138099232971
**@nicbarkeragain**
this will be slower unless your compiler is really bad. cmov exists.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain Compilers already inline them."
type: archive
source: twitter
source_url: "https://x.com/wetfsdffsdasd/status/1947643887935230408"
author: "wetfsdffsdasd"
handle: wetfsdffsdasd
post_id: "1947643887935230408"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Compilers already inline them."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/wetfsdffsdasd/status/1947643887935230408
- Author: wetfsdffsdasd (@wetfsdffsdasd)
- Posted: 2025-07-22 13:04:23
## Branch
**1/** **@wetfsdffsdasd** ^1947643887935230408
**@nicbarkeragain**
Compilers already inline them. unless you are using some garbage new trend language
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain What kind of applications is this practically useful for? Shaders / GPU stuff? Ultra low latency fintech stuff? Embedded?"
type: archive
source: twitter
source_url: "https://x.com/yenwoda/status/1947634859536511220"
author: "yenwoda"
handle: yenwoda
post_id: "1947634859536511220"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain What kind of applications is this practically useful for? Shaders / GPU stuff? Ultra low latency fintech stuff? Embedded?"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/yenwoda/status/1947634859536511220
- Author: yenwoda (@yenwoda)
- Posted: 2025-07-22 12:28:30
## Branch
**1/** **@yenwoda** ^1947634859536511220
**@nicbarkeragain**
What kind of applications is this practically useful for? Shaders / GPU stuff? Ultra low latency fintech stuff? Embedded?
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,38 @@
---
title: "@nicbarkeragain you can find a lot of examples of this method in assembly books."
type: archive
source: twitter
source_url: "https://x.com/zehavoc/status/1947581049317269616"
author: "Djamé.."
handle: zehavoc
post_id: "1947581049317269616"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain you can find a lot of examples of this method in assembly books."
in_reply_to: ""
parent_post_id: "1947506506922098959"
---
## Source
- URL: https://x.com/zehavoc/status/1947581049317269616
- Author: Djamé.. (@zehavoc)
- Posted: 2025-07-22 08:54:41
## Branch
**1/** **@zehavoc** ^1947581049317269616
**@nicbarkeragain**
you can find a lot of examples of this method in assembly books. Like for example in the powerpc compiler writing guide (3.1.5)
https://cr.yp.to/2005-590/powerpc-cwg.pdf
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,38 @@
---
title: "@nicbarkeragain People have been whipped for less than this."
type: archive
source: twitter
source_url: "https://x.com/BackwoodsEnginr/status/1947860526551240723"
author: "Backwoods Engineer - THE ORIGINAL"
handle: BackwoodsEnginr
post_id: "1947860526551240723"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain People have been whipped for less than this."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/BackwoodsEnginr/status/1947860526551240723
- Author: Backwoods Engineer - THE ORIGINAL (@BackwoodsEnginr)
- Posted: 2025-07-23 03:25:13
## Branch
**1/** **@BackwoodsEnginr** ^1947860526551240723
**@nicbarkeragain**
People have been whipped for less than this.
Try that in embedded programming, and you might be.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,38 @@
---
title: "@nicbarkeragain Seems like the problem is that both options are badly written and it's a matter of luck whether the compiler optimises it or not."
type: archive
source: twitter
source_url: "https://x.com/BenSimsTech/status/1947984883936354406"
author: "Ben Sims"
handle: BenSimsTech
post_id: "1947984883936354406"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Seems like the problem is that both options are badly written and it's a matter of luck whether the compiler optimises it or not."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/BenSimsTech/status/1947984883936354406
- Author: Ben Sims (@BenSimsTech)
- Posted: 2025-07-23 11:39:22
## Branch
**1/** **@BenSimsTech** ^1947984883936354406
**@nicbarkeragain**
Seems like the problem is that both options are badly written and it's a matter of luck whether the compiler optimises it or not.
I wouldn't encourage using muls instead of branches as a general rule, instead I'd be telling people to check their compiled code and adjust if needed
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,38 @@
---
title: "@nicbarkeragain Ternary operator in openmp GPU code is along the same lines."
type: archive
source: twitter
source_url: "https://x.com/ChristosArgyrop/status/1947895847078826458"
author: "Christos Argyropoulos MD PhD 0kale/acc 🇺🇸"
handle: ChristosArgyrop
post_id: "1947895847078826458"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Ternary operator in openmp GPU code is along the same lines."
in_reply_to: ""
parent_post_id: "1947506506922098959"
---
## Source
- URL: https://x.com/ChristosArgyrop/status/1947895847078826458
- Author: Christos Argyropoulos MD PhD 0kale/acc 🇺🇸 (@ChristosArgyrop)
- Posted: 2025-07-23 05:45:34
## Branch
**1/** **@ChristosArgyrop** ^1947895847078826458
**@nicbarkeragain**
Ternary operator in openmp GPU code is along the same lines.
Nice tweetorial!
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain Nest trick who cares"
type: archive
source: twitter
source_url: "https://x.com/MamboJambo85/status/1948001988547109359"
author: "imperius"
handle: MamboJambo85
post_id: "1948001988547109359"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Nest trick who cares"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/MamboJambo85/status/1948001988547109359
- Author: imperius (@MamboJambo85)
- Posted: 2025-07-23 12:47:20
## Branch
**1/** **@MamboJambo85** ^1948001988547109359
**@nicbarkeragain**
Nest trick who cares
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,39 @@
---
title: "@nicbarkeragain I love using arrays as jump tables for operations."
type: archive
source: twitter
source_url: "https://x.com/MrJayLC/status/1948092447596187880"
author: "John"
handle: MrJayLC
post_id: "1948092447596187880"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain I love using arrays as jump tables for operations."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/MrJayLC/status/1948092447596187880
- Author: John (@MrJayLC)
- Posted: 2025-07-23 18:46:47
## Branch
**1/** **@MrJayLC** ^1948092447596187880
**@nicbarkeragain**
I love using arrays as jump tables for operations.
People hate it because it's convoluted :|
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain remind me of rust"
type: archive
source: twitter
source_url: "https://x.com/SYSUlindragon/status/1948155486706315529"
author: "linrl3"
handle: SYSUlindragon
post_id: "1948155486706315529"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain remind me of rust"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/SYSUlindragon/status/1948155486706315529
- Author: linrl3 (@SYSUlindragon)
- Posted: 2025-07-23 22:57:17
## Branch
**1/** **@SYSUlindragon** ^1948155486706315529
**@nicbarkeragain**
remind me of rust
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain This is what Apple does with the NPU and CoreML, isn’t it? Compiling the entire inference process into a single path, like the final boss of branchless programming?"
type: archive
source: twitter
source_url: "https://x.com/_m16b/status/1947830481258451329"
author: "mordecai"
handle: _m16b
post_id: "1947830481258451329"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain This is what Apple does with the NPU and CoreML, isn’t it? Compiling the entire inference process into a single path, like the final boss of branchless programming?"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/_m16b/status/1947830481258451329
- Author: mordecai (@_m16b)
- Posted: 2025-07-23 01:25:50
## Branch
**1/** **@_m16b** ^1947830481258451329
**@nicbarkeragain**
This is what Apple does with the NPU and CoreML, isn’t it? Compiling the entire inference process into a single path, like the final boss of branchless programming?
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,41 @@
---
title: "The key here is that CPUs mostly only have two options:"
type: archive
source: twitter
source_url: "https://x.com/andrecasaldev/status/1947936114343383335"
author: "André Casal"
handle: andrecasaldev
post_id: "1947936114343383335"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "The key here is that CPUs mostly only have two options:"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/andrecasaldev/status/1947936114343383335
- Author: André Casal (@andrecasaldev)
- Posted: 2025-07-23 08:25:35
## Branch
**1/** **@andrecasaldev** ^1947936114343383335
The key here is that CPUs mostly only have two options:
1. Assume the branch will occur and read the instruction it points to
2. Assume the branch will not occur and read the instruction below it
Either way, if the CPU predicted wrong, it will have to discard the instruction and go read the correct one, losing performance.
Branchless programming is fascinating, even if not always very clear 😁
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain Google TCO ."
type: archive
source: twitter
source_url: "https://x.com/awksedgreep/status/1947859743063585197"
author: "awksedgreep"
handle: awksedgreep
post_id: "1947859743063585197"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Google TCO ."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/awksedgreep/status/1947859743063585197
- Author: awksedgreep (@awksedgreep)
- Posted: 2025-07-23 03:22:06
## Branch
**1/** **@awksedgreep** ^1947859743063585197
**@nicbarkeragain**
Google TCO . . . thank me later.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain I still wonder if you can make compiler to auto-non-branchify code? Or transpiler."
type: archive
source: twitter
source_url: "https://x.com/bigboosbro08/status/1947817883377299526"
author: "bigbossbro08"
handle: bigboosbro08
post_id: "1947817883377299526"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain I still wonder if you can make compiler to auto-non-branchify code? Or transpiler."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/bigboosbro08/status/1947817883377299526
- Author: bigbossbro08 (@bigboosbro08)
- Posted: 2025-07-23 00:35:46
## Branch
**1/** **@bigboosbro08** ^1947817883377299526
**@nicbarkeragain**
I still wonder if you can make compiler to auto-non-branchify code? Or transpiler. Because writing non-branched code is extremely hard to do.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain goes hard if you're a compsci undergrad"
type: archive
source: twitter
source_url: "https://x.com/eyepatchjack/status/1948042066510188544"
author: "Eye Patch Jack"
handle: eyepatchjack
post_id: "1948042066510188544"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain goes hard if you're a compsci undergrad"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/eyepatchjack/status/1948042066510188544
- Author: Eye Patch Jack (@eyepatchjack)
- Posted: 2025-07-23 15:26:36
## Branch
**1/** **@eyepatchjack** ^1948042066510188544
**@nicbarkeragain**
goes hard if you're a compsci undergrad
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain Interesting 🤔"
type: archive
source: twitter
source_url: "https://x.com/gavranha/status/1947817973088915782"
author: "J. S. Lopes"
handle: gavranha
post_id: "1947817973088915782"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Interesting 🤔"
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/gavranha/status/1947817973088915782
- Author: J. S. Lopes (@gavranha)
- Posted: 2025-07-23 00:36:08
## Branch
**1/** **@gavranha** ^1947817973088915782
**@nicbarkeragain**
Interesting 🤔
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain Close enough, the for loop is a branch, however the code can be compiled so that it has a branch that is likely to be taken."
type: archive
source: twitter
source_url: "https://x.com/marcosdanix/status/1948024899571785906"
author: "Marcos Pires"
handle: marcosdanix
post_id: "1948024899571785906"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain Close enough, the for loop is a branch, however the code can be compiled so that it has a branch that is likely to be taken."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/marcosdanix/status/1948024899571785906
- Author: Marcos Pires (@marcosdanix)
- Posted: 2025-07-23 14:18:23
## Branch
**1/** **@marcosdanix** ^1948024899571785906
**@nicbarkeragain**
Close enough, the for loop is a branch, however the code can be compiled so that it has a branch that is likely to be taken.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain İt's pretty hard to tell when removing a branch is actually going to help your performance."
type: archive
source: twitter
source_url: "https://x.com/reidatcheson/status/1948143067946508415"
author: "Reid Atcheson"
handle: reidatcheson
post_id: "1948143067946508415"
date: 2025-07-23
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain İt's pretty hard to tell when removing a branch is actually going to help your performance."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/reidatcheson/status/1948143067946508415
- Author: Reid Atcheson (@reidatcheson)
- Posted: 2025-07-23 22:07:56
## Branch
**1/** **@reidatcheson** ^1948143067946508415
**@nicbarkeragain**
İt's pretty hard to tell when removing a branch is actually going to help your performance. İ see people make lucky guesses on this & pat themselves in the back when some benchmark metric improves, but performance counters implicate some completely unrelated cause
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,37 @@
---
title: "@nicbarkeragain If you're handling integers, just use a full bitmask and use boolean AND."
type: archive
source: twitter
source_url: "https://x.com/MichaelDChaney/status/1949180928623845610"
author: "Michael Chaney"
handle: MichaelDChaney
post_id: "1949180928623845610"
date: 2025-07-26
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "@nicbarkeragain If you're handling integers, just use a full bitmask and use boolean AND."
in_reply_to: ""
parent_post_id: "1947506500194472221"
---
## Source
- URL: https://x.com/MichaelDChaney/status/1949180928623845610
- Author: Michael Chaney (@MichaelDChaney)
- Posted: 2025-07-26 18:52:02
## Branch
**1/** **@MichaelDChaney** ^1949180928623845610
**@nicbarkeragain**
If you're handling integers, just use a full bitmask and use boolean AND. It's probably 50 or more times as fast as multiply as it can complete in a single clock cycle.
## Related
- Spine: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
@@ -0,0 +1,44 @@
---
title: "\"Branchless Programming\" is a term used to describe a programming style that improves performance by avoiding branches (e.g."
type: archive
source: twitter
source_url: "https://x.com/nicbarkeragain/status/1947506500194472221"
author: "Nic Barker"
handle: nicbarkeragain
post_id: "1947506500194472221"
date: 2025-07-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- nicbarkeragain
description: "\"Branchless Programming\" is a term used to describe a programming style that improves performance by avoiding branches (e.g."
in_reply_to: ""
---
## Source
- URL: https://x.com/nicbarkeragain/status/1947506500194472221
- Author: Nic Barker (@nicbarkeragain)
- Posted: 2025-07-22 03:58:27
## Thread
**1/** **@nicbarkeragain** ^1947506500194472221
"Branchless Programming" is a term used to describe a programming style that improves performance by avoiding branches (e.g. if statements and similar). One of the most common branchless tricks is to use multiplication in place of an if statement:
![](https://pbs.twimg.com/media/Gwbt-IjbEAQTRx4?format=jpg&name=orig)
Branches: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-sreekotay-id-usually-use-or-but-same-idea]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-anicic_filip-a-more-compact-example-is-using-a-bitmask-integer]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-VPCOMPRESSB-im-branch-free-by-default-its-not-for]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-la_ledda-i-have-no-idea-if-it-improves-performance-in-the]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-viertausend1-great-post-which-color-scheme-font-is-used-in-the]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-gonenb-looks-pretty-useless-to-me-in-this-case-if-you]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-wcolefranks-1-if-x-else-0]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-augeeidos-its-also-a-key-component-in-developing-good]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-JustSlavic-one-additional-read-instead-of-using-the-result]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-RussellPolo-a-really-long-time-ago-programming-a-simple-game]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-macsmol-australia-represent-https-www-youtube-com-watch-v]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-stuartcarnie-it-also-matters-how-random-the-data-is-if-the]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-macsmol-you-nerd-sniped-me-to-actually-try-the-sth-out]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-etozheya42-thats-cool]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-johan_tlb-nice-til]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-jakubtomsu_-clang-failed-to-recognize-it-should-use-a-select]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-XylnZ-wait-i-am-cooked-are-you-trolling-or-serious-it]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-paulopacitti-10x-better-i-thought-branch-prediction-wouldnt]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-SMrrandom-why-should-you-do-something-that-your-compiler-do]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-feliperybas-so-programming-by-object-literals]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-RoseSilicon-if-you-are-doing-a-for-loop-you-are-still]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-yenwoda-what-kind-of-applications-is-this-practically]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-wetfsdffsdasd-compilers-already-inline-them-unless-you-are]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-weirdcuttlefish-this-will-be-slower-unless-your-compiler-is]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-RaykiruS-int-val-this-is-valid-syntax-c-is-wild-with-the]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-osoleve-is-it-for-performance-reasons-ive-only-seen-it-in]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-RaykiruS-thats-cool-but-also-compilers-know-how-to-do-it]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-narator287-you-mean-functional-programming]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-occidensus-what-is-the-measured-performance-impact]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-eigen_spectra-godbolt-example-of-branchless-vs-branchfull-if]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-_benwick-its-good-inside-hot-loops-and-shaders-but-its-not]], [[arLine truncated
**2/** **@nicbarkeragain** ^1947506503176622501
This approach is similar to how "jump tables" are implemented by the compiler to speed up switch statements. By using the enum value directly as an index into a table of addresses, we can avoid needing to compare / branch and instead just compute the address and jump directly.
**3/** **@nicbarkeragain** ^1947506506922098959
While this is a bit of a contrived example, branchless programming is a deep well full of really cool tricks, I'd encourage you to dig through some of the amazing things people have done if you haven't heard of the term before 😁
Branches: [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-zehavoc-you-can-find-a-lot-of-examples-of-this-method-in]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-daniel_collin-its-funny-when-some-people-say-branches-are]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-22-_benwick-i-think-its-a-cool-field-like-only-using-stack]], [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe/2025-07-23-ChristosArgyrop-ternary-operator-in-openmp-gpu-code-is-along-the]]
+1
View File
@@ -10,5 +10,6 @@ tags:
---
- [[archive/threads/nicbarkeragain/2025-07-15-i-cant-help-but-have-this-feeling-that-were]]
- [[archive/threads/nicbarkeragain/2025-07-22-branchless-programming-is-a-term-used-to-describe]]
- [[archive/threads/nicbarkeragain/2026-08-03-imo-basically-every-object-creation-api-you-have]]
- [[archive/threads/nicbarkeragain/2026-08-05-an-example-of-this-a-classic-way-to-construct-a]]