Skip to contentSkip to conversation

armv8/cache.S: Triple with single instruction

PATCH In review Pierre-Clément Tosi 2 participants 2 messages Aug 27, 2021 – Sep 24, 2021 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 armv8/cache.S: Triple with single instruction

Replace the current 2-instruction 2-step tripling code by a corresponding single instruction leveraging ARMv8-A's "flexible second operand as a register with optional shift". This has the added benefit (albeit arguably negligible) of reducing the final code size.

Fix the comment as the tripled cache level is placed in x12, not x0.

---
 arch/arm/cpu/armv8/cache.S | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/cpu/armv8/cache.S +1 -2
index aabb3dff61..5051597f6f 100644
@@ -80,8 +80,7 @@ ENTRY(__asm_dcache_all)
 	/* x15 <- return address */
 
 loop_level:
-	lsl	x12, x0, #1
-	add	x12, x12, x0		/* x0 <- tripled cache level */
+	add	x12, x0, x0, lsl #1	/* x12 <- tripled cache level */
 	lsr	x12, x10, x12
 	and	x12, x12, #7		/* x12 <- cache type */
 	cmp	x12, #2
Signature · 5 lines
2.33.0.259.gc128427fd7-goog


-- 
Pierre
#1 lore raw
Quoted 8 lines · Pierre-Clément Tosi

Replace the current 2-instruction 2-step tripling code by a corresponding single instruction leveraging ARMv8-A's "flexible second operand as a register with optional shift". This has the added benefit (albeit arguably negligible) of reducing the final code size.

Fix the comment as the tripled cache level is placed in x12, not x0.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom