]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PATCH] RISC-V: Fix missing return in expand_vec_perm
authorJin Ma <jinma@linux.alibaba.com>
Tue, 2 Jun 2026 13:07:00 +0000 (07:07 -0600)
committerJeff Law <jeffrey.law@oss.qualcomm.com>
Tue, 2 Jun 2026 13:07:00 +0000 (07:07 -0600)
In expand_vec_perm, the branch handling a selector that is a constant
duplicate (all indices identical) emits a VLMAX vrgather and is then
meant to be done.  The missing return let control fall through into the
generic modulo-index handling below, which recomputes and overwrites
the target with another gather sequence.

Add the return so the duplicate path stops after the gather.

No test case is added: without the return the first gather is a dead
store to the target that the generic path immediately overwrites, so it
is removed by later RTL dead-store elimination and the final assembly is
identical with and without the fix.  No test can therefore observe the
change.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vec_perm): Add missing return
after emit_vlmax_gather_insn.

gcc/config/riscv/riscv-v.cc

index b7dd1c8279adf9ebcca6b5a07f201b60128ac9e3..2f1d1be50d69daf3f09b404f8384b9773e35574c 100644 (file)
@@ -3320,6 +3320,7 @@ expand_vec_perm (rtx target, rtx op0, rtx op1, rtx sel)
          op = op1;
        }
       emit_vlmax_gather_insn (target, op, sel);
+      return;
     }
 
   /* Note: vec_perm indices are supposed to wrap when they go beyond the