https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111467
Bug ID: 111467 Summary: REE failing to eliminate redundant extension due to multiple reaching def(s) Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: vineetg at gcc dot gnu.org Reporter: vineetg at gcc dot gnu.org CC: jeffreyalaw at gmail dot com, jivanhakobyan9 at gmail dot com, kito at gcc dot gnu.org, palmer at gcc dot gnu.org Target Milestone: --- For the trivial test case below (credit goes to Palmer for mentioning this almost 2 years ago). int foo6(int a, int b) { return a > b ? a : b; } -O2 -march=rv64gc foo6: mv a5,a1 bge a1,a0,.L5 mv a5,a0 .L5: sext.w a0,a5 ret REE fails to eliminate the sign extension due to multiple reaching definitions constraint. I don't know how involved or runtime cost relaxing the constraint is, so opening this PR to investigate. FWIW a zba build generates a max insn, eliminating the sext.w, but the vanilla case shows where things can possibly be improved.