https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116999
Bug ID: 116999
Summary: Fold SVE whilelt/le comparisons with max int value to
ptrue
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: ktkachov at gcc dot gnu.org
Target Milestone: ---
Target: aarch64
Example testcase:
#include <arm_sve.h>
#include <climits>
svbool_t
foo_s32_le (int32_t x)
{
return svwhilele_b64_s32 (x, INT_MAX);
}
svbool_t
foo_s64_le (int64_t x)
{
return svwhilele_b64_s64 (x, LONG_LONG_MAX);
}
can avoid generating the WHILELE instructions and just generate a PTRUE.
This is as per the WHILELE documentation:
"If the second scalar operand is equal to the maximum signed integer value then
a condition which includes an equality test can never fail and the result will
be an all-true predicate."
Note that we probably want to look at the use of the flags from the whilele as
well. If we cannot prove that the NZCV are unused then we have to generate a
PTRUES instead, I think