On Fri, Oct 23, 2026 at 10:47:50PM -0600, Jeff Law wrote:
On 9/7/26 8:42 PM, Robert Guthrie wrote:
Sometimes its better to ask for help as you work through these
things. Ideally with before/after dumps and the patch you're
working with. GCC is fairly complex and often even very
experienced developers need to throw things under the debugger to
really understand what's happening.
Thanks -- I didn't want to ask anyone to debug my stuff, and
anyways it took a bit of time but was straightforward. Most of the
debugging
has just been me resolving my misunderstandings about what certain
functions
do or variables are for, which is helpful for me.
Well, we do all get busy, as you've no doubt noticed. Once you hit
mid Sept most of us hunker down to get ready for Cauldron, then spend
time digging out of all the missed work when we get back.
No worries at all! It is of course a quite minor issue, so I am very
appreciative of any time.
I think there are two related ideas here.
1. At a high level, maintain a CFG where we just don't have multiple
return-only BBs, while in cfglayout mode. This is what I did in the other email
you responded to,
based on how I interpreted something you suggested earlier.
That worked in my original basic factorial function (and in other places in
bootstrap/tests)
because both ret's were part of return-only basic blocks, so one of them got
eliminated.
This elimination happened before they were actually ordered consecutively so
that part actually didn't matter.
Of course if I instead had some code like
.L1:
mv a0, t0
ret
.L2:
ret
Then I could still end up with two ret's in a row because the .L1 block isn't
ret-only.
I feel like this is not an elegant way to do it -- it feels somewhat arbitrary.
There might also be consequences I don't know about.
But that is why my change _did_ actually eliminate some unnecessary ret insns.
2. The other idea that I think you are suggesting now is something like this
transformation:
beqz t1, L2
...
.L1:
mv a0, t0
ret
.L2:
ret
could become
beqz t1, L2
...
.L1:
mv a0, t0
.L2:
ret
where once the linear sequence is determined I look for sequential rets and
rewrite, presumably in cfgrtl mode.
I did _try_ to do this, but it was both less obvious where to put it, and much
harder to figure out how to do correctly.
I can't recall what my last attempt was -- I remember being unsure which
invariants I had to maintain at that stage
and getting some invalid insn stream errors.
I may give this another shot based on what you've said and see if I can do it
this way, rather than the previous way
(though if there is no natural place to put it, I will probably give it a rest:
at least I have had fun exploring!)
Best
Robert