[avr] PR114975: Better 8-bit popcount detection.
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Testing passed
|
Commit Message
Add a pattern for better popcount detection.
Ok for master?
Johann
--
AVR: target/114975 - Add combine-pattern for __popcountqi2.
PR target/114975
gcc/
* config/avr/avr.md: Add combine pattern for
8-bit popcount detection.
gcc/testsuite/
* gcc.target/avr/pr114975-popcount.c: New test.
Comments
On 5/7/24 11:25 AM, Georg-Johann Lay wrote:
> Add a pattern for better popcount detection.
>
> Ok for master?
>
> Johann
>
> --
>
> AVR: target/114975 - Add combine-pattern for __popcountqi2.
>
> PR target/114975
> gcc/
> * config/avr/avr.md: Add combine pattern for
> 8-bit popcount detection.
>
> gcc/testsuite/
> * gcc.target/avr/pr114975-popcount.c: New test.
OK
jeff
@@ -8527,6 +8542,19 @@ (define_expand "popcountsi2"
operands[2] = gen_reg_rtx (HImode);
})
+(define_insn_and_split "*popcounthi2.split8"
+ [(set (reg:HI 24)
+ (zero_extend:HI (popcount:QI (match_operand:QI 0 "register_operand"))))]
+ "! reload_completed"
+ { gcc_unreachable(); }
+ "&& 1"
+ [(set (reg:QI 24)
+ (match_dup 0))
+ (set (reg:QI 24)
+ (popcount:QI (reg:QI 24)))
+ (set (reg:QI 25)
+ (const_int 0))])
+
(define_insn_and_split "*popcounthi2.libgcc_split"
[(set (reg:HI 24)
(popcount:HI (reg:HI 24)))]
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Os" } */
+
+typedef __UINT8_TYPE__ uint8_t;
+
+uint8_t use_pop1 (int y, uint8_t x)
+{
+ return 1 + __builtin_popcount (x);
+}
+
+uint8_t use_pop2 (uint8_t x)
+{
+ x += 1;
+ return 1 - __builtin_popcount (x);
+}
+
+/* { dg-final { scan-assembler-times "__popcountqi2" 2 } } */