On 7/31/23 06:14, Wang, Yanzhang wrote:
Thanks your comments, Jeff and Robin
Is the mulh case somehow common or critical?
Well, I would actually back up even further. What were the
circumstances that led to the mulh with a zero operand?
I think you both mentioned why should we add the mulh * 0 simplify.
Unfortunately, I have no such a benchmark to explain the criticalness. We found
there're some cases that exists in simplify_binary_operation in simplify-rtx.cc
but not working for RISC-V backend. For example,
- mult * 0 exists, but RISC-V has additional mulh * 0
- add + 0 / sub - 0 exists, but RISC-V has additional (madc + adc) + 0
- ...
So we want to do some complement to make the simplify can cover more cases.
That's the basic idea why we do these shortcut optimizations.
But the right place to handle this stuff is probably in the generic
code, with a few exceptions.
So even if you don't have a benchmark, just having non-intrinsic/builtin
code which triggers these cases would be helpful so that we can figure
out the best place to fix this problem. What I want to avoid is adding
a bunch of patterns in the RISC-V backend for cases that are better
handled by generic optimization passes.
Jeff