Christophe Leroy 41d65207de powerpc/atomics: Use immediate operand when possible
Today we get the following code generation for atomic operations:

	c001bb2c:	39 20 00 01 	li      r9,1
	c001bb30:	7d 40 18 28 	lwarx   r10,0,r3
	c001bb34:	7d 09 50 50 	subf    r8,r9,r10
	c001bb38:	7d 00 19 2d 	stwcx.  r8,0,r3

	c001c7a8:	39 40 00 01 	li      r10,1
	c001c7ac:	7d 00 18 28 	lwarx   r8,0,r3
	c001c7b0:	7c ea 42 14 	add     r7,r10,r8
	c001c7b4:	7c e0 19 2d 	stwcx.  r7,0,r3

By allowing GCC to choose between immediate or regular operation,
we get:

	c001bb2c:	7d 20 18 28 	lwarx   r9,0,r3
	c001bb30:	39 49 ff ff 	addi    r10,r9,-1
	c001bb34:	7d 40 19 2d 	stwcx.  r10,0,r3
	--
	c001c7a4:	7d 40 18 28 	lwarx   r10,0,r3
	c001c7a8:	39 0a 00 01 	addi    r8,r10,1
	c001c7ac:	7d 00 19 2d 	stwcx.  r8,0,r3

For "and", the dot form has to be used because "andi" doesn't exist.

For logical operations we use unsigned 16 bits immediate.
For arithmetic operations we use signed 16 bits immediate.

On pmac32_defconfig, it reduces the text by approx another 8 kbytes.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Acked-by: Segher Boessenkool <segher@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/2ec558d44db8045752fe9dbd29c9ba84bab6030b.1632236981.git.christophe.leroy@csgroup.eu
2021-11-30 11:45:57 +11:00
..
2021-11-05 08:15:46 -07:00
2021-09-08 15:32:35 -07:00
2021-04-08 21:17:42 +10:00
2020-08-11 14:13:24 -07:00
2021-08-10 23:14:55 +10:00
2020-10-07 22:34:47 +11:00
2020-12-05 21:49:52 +11:00
2021-03-24 14:09:29 +11:00
2021-03-24 14:09:30 +11:00
2020-06-05 12:39:30 -07:00
2021-07-01 11:06:03 -07:00
2021-07-02 12:54:34 -07:00
2021-02-09 01:09:44 +11:00
2019-07-13 16:08:36 -07:00
2019-07-13 16:08:36 -07:00
2021-09-03 22:54:12 +10:00
2018-05-25 12:04:43 +10:00
2020-07-27 00:01:32 +10:00
2021-07-08 11:48:23 -07:00
2018-07-30 22:48:21 +10:00
2019-05-01 16:45:05 +10:00
2021-08-23 19:28:20 +10:00
2020-12-04 01:01:19 +11:00
2021-02-09 00:10:50 +11:00