-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Closed
Description
For some constants, GCC is able to generate sequences of add where LLVM generates mul. I have checked all constants between 1 and 100 (https://godbolt.org/z/rxej44fGj):
For all of the examples below(11, 13, 19, 21, 25, 27, 35, 37, 41, 49, 51, 69, 73, 81, 85), LLVM generates
mulK:
mov w8, K
mul w0, w0, w8
retmul11:
add w1, w0, w0, lsl 2
add w0, w0, w1, lsl 1
retmul13:
add w1, w0, w0, lsl 1
add w0, w0, w1, lsl 2
retmul19:
add w1, w0, w0, lsl 3
add w0, w0, w1, lsl 1
retmul21:
add w1, w0, w0, lsl 2
add w0, w0, w1, lsl 2
retmul25:
add w0, w0, w0, lsl 2
add w0, w0, w0, lsl 2
retmul27:
add w0, w0, w0, lsl 1
add w0, w0, w0, lsl 3
retmul35:
add w1, w0, w0, lsl 4
add w0, w0, w1, lsl 1
retmul37:
add w1, w0, w0, lsl 3
add w0, w0, w1, lsl 2
retmul41:
add w1, w0, w0, lsl 2
add w0, w0, w1, lsl 3
ret
mul49:
add w1, w0, w0, lsl 1
add w0, w0, w1, lsl 4
retmul51:
add w0, w0, w0, lsl 1
add w0, w0, w0, lsl 4
retmul69:
add w1, w0, w0, lsl 4
add w0, w0, w1, lsl 2
retmul73:
add w1, w0, w0, lsl 3
add w0, w0, w1, lsl 3
retmul81:
add w0, w0, w0, lsl 3
add w0, w0, w0, lsl 3
retmul85:
add w0, w0, w0, lsl 2
add w0, w0, w0, lsl 4
ret