On 11/2/26 1:16 AM, Michiel Derhaeg wrote:
+}
+
+/* Check for RISCV_FUSE_BONDED_MUL fusion.
+ prev (mulh/mulhu/mulhsu) and curr (mul) of the same inputs, with the
+ high-part destination distinct from both inputs. */
+
+static bool
+riscv_fuse_bonded_mul (rtx_insn *prev, rtx_insn *curr)
You should check that PREV is not marked for fusion. It's likely to be
marked, but better to be sure.
I presume you mean checking this in
riscv_depends_on_lowpart_bonded_mul_p before calling
riscv_fuse_bonded_mul.
I'm not 100% sure where you want to put it, but the idea is to makes
sure that if you have a sequence like A, B C where A & B have been
marked for fusion by setting SCHED_GROUP_P on B that you don't then set
it on C, even if it looks like B and C would fuse.
I'm not aware of any design where DEC based fusion can do that cascading
fusion -- doing so would present a real timing challenge in the
decoder. And if you were to mark the B/C fusion by setting
SCHED_GROUP_P on C, then the set, ABC has to move around as an atomic
unit within the scheduler which is bad for performance.
Huh? If you're changing code generation in an expander based on FUSION
things, then you're likely doing something wrong. I'd suggest dropping
these hunks for now and returning to whatever caused you to want to add
it later. It's a sign you're tackling a problem in the wrong way.
We really need the highpart to appear first or the fusion won't be
found. The conditionals aren't really needed, this change can be made
independent of the fusion being available.
I'm aware of the restriction. But this is not the place to tackle that
problem. THe work from Artimey a year or so ago will scurry around and
find the two fusible insns for this case and bring them together late in
RTL pipeline. If that's not working, then you should debug that
problem, not introduce SCHED_GROUP_P or priority stuff during RTL expansion.
But now that you mention it we could probably adjust priority
here instead.
No, that's a bad idea too.
Know that we do have to change codegen whatever solution we pick because
some highpart asm templates swap their input operands and we swap
muldi3's inputs to match. Our fusion requires this order to match for
both instructions. I would like to have a system to express register
constraints like this for fusions, but that doesn't exist yet.
Fusion is an optimization, not a correctness issue. While we don't want
to miss fusions, doing so isn't fatal. I would carve this out of the
patch and get the other stuff fixed up and integrated since the rest
looks good and likely provides some benefit on your design. Then come
back to this one issue separately and address whatever problems we need to.
Jeff