https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116358

--- Comment #5 from Manolis Tsamis <tsamismanolis at gmail dot com> ---
I had some trouble figuring the preferred way to address this. I made a choice
by answering these questions:

1) Should the aarch64 min/max expand pattern be improved?

This comment hints that we should get a cmp+csel when expanding this rather
than a libcall:

;; Expander for integer smin, smax, umin.  Mainly used to generate
;; straightforward RTL for TARGET_CSSC.  When that is not available
;; FAIL and let the generic expanders generate the CMP + CSEL sequences,
;; except for the SMIN and SMAX with zero cases, for which we have a
;; single instruction even for the base architecture.

Although aarch64.md could be changed to fix this, this wouldn't prevent similar
issues from happening in other cases.

2) Should force_operand handle this in a better way?

In theory, the expression involved can be forced in a register, but it's not
due to implementation details of force_operand. But I also believe changing
force_operand is too risky and out of scope.

3) Should noce_can_force_operand reject this RTL?

noce_can_force_operand is already based on internals of force_operand and it
would make sense to fix it there, but it doesn't look possible. As far as
force_operand is conserned there's no error, just a libcall being emitted.
Hence we would have to hardcode cases in noce_can_force_operand which is what
r15-2890-g72c9b5f438f22c tried to avoid compared to the previous
implementation.

4) Should we reject calls being generated in noce_convert_multiple_sets?

Although this initially felt like a workaround, I believe is the best solution
here. The reasoning is that, regardless of other factors,
noce_convert_multiple_sets should never emit a call expression. Since this was
already done for jump instructions, the change is also minimal:

diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc
index da59c907891..b136d7dbbba 100644
--- a/gcc/ifcvt.cc
+++ b/gcc/ifcvt.cc
@@ -3550,7 +3550,7 @@ noce_convert_multiple_sets (struct noce_if_info *if_info)
     return false;

   for (insn = seq; insn; insn = NEXT_INSN (insn))
-    if (JUMP_P (insn)
+    if (JUMP_P (insn) || CALL_P (insn)
        || recog_memoized (insn) == -1)
       return false;
-- 

Sent to the lists:
https://gcc.gnu.org/pipermail/gcc-patches/2024-August/661145.html

Reply via email to