]> git.ipfire.org Git - thirdparty/gcc.git/commit
expand: Use the correct mode for store flags for popcount [PR116480]
authorAndrew Pinski <quic_apinski@quicinc.com>
Sun, 25 Aug 2024 17:10:06 +0000 (10:10 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Mon, 26 Aug 2024 09:35:05 +0000 (02:35 -0700)
commit53b86cac7e77ddff4e8a215408f7331ebc5bf22c
treef6a8e66e3ef2f5e9b547d8cfe5e9a72b2faee124
parentb4ac2c23d8745d98984954e88f02aa73f1c3594b
expand: Use the correct mode for store flags for popcount [PR116480]

When expanding popcount used for equal to 1 (or rather __builtin_stdc_has_single_bit),
the wrong mode was bsing used for the mode of the store flags. We were using the mode
of the argument to popcount but since popcount's return value is always int, the mode
of the expansion here should have been the mode of the return type rater than the argument.

Built and tested on aarch64-linux-gnu with no regressions.
Also bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/116480

gcc/ChangeLog:

* internal-fn.cc (expand_POPCOUNT): Use the correct mode
for store flags.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr116480-1.c: New test.
* gcc.dg/torture/pr116480-2.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/internal-fn.cc
gcc/testsuite/gcc.dg/torture/pr116480-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr116480-2.c [new file with mode: 0644]