[PATCH] expand_mult: Look through vector mode
Jeff Law
jeffrey.law@oss.qualcomm.com
Wed Oct 7 12:51:42 GMT 2026
On 10/7/26 3:26 AM, Stefan Schulze Frielinghaus wrote:
> On Sat, Sep 19, 2026 at 08:49:08AM +0200, Stefan Schulze Frielinghaus wrote:
>> From: Stefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
>>
>> When expand_mult handles a constant vector multiplier where the scalar
>> operand is a CONST_WIDE_INT, then also look through the vector mode
>> while determining the shift amount since here we need the scalar mode.
>> Note, when we call later on into expand_shift we need the vector mode,
>> i.e., only for the shift amount we need the scalar mode.
>>
>> I guess it would have been sound to call unconditionally into
>> GET_MODE_INNER, i.e., even for scalars (kinda similar as for
>> GET_MODE_UNIT_BITSIZE from above), however, I think checking for
>> VECTOR_MODE_P here makes the intend explicit.
>>
>> PR middle-end/127474
>>
>> gcc/ChangeLog:
>>
>> * expmed.cc (expand_mult): Look through vector mode.
>>
>> gcc/testsuite/ChangeLog:
>>
>> * gcc.target/s390/pr127474.c: New test.
>> ---
>> Bootstrapped and regtested for
>> - aarch64-unknown-linux-gnu
>> - powerpc64le-unknown-linux-gnu
>> - s390x-ibm-linux-gnu
>> - x86_64-pc-linux-gnu
>> Ok for mainline?
> It's been in trunk for over two weeks. Ok if I backport to 14/15/16?
> For gcc 14 I will have to adapt the test since there we do not have z17
> support for s390. However, this is a latent bug and IMHO should be fixed
> for gcc 14, too.
Yes, and your call on how to best handle the test.
jeff
More information about the Gcc-patches
mailing list