https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122769
--- Comment #11 from Vineet Gupta <vineetg at gcc dot gnu.org> ---
FTR, just for completeness it seems ifcvt bits to handle cond arithmetic with
zero were added back in 2023 (for gcc-14 release), specifically patch 2/5 below
for shift ops as expected by the test in the PR.
2023-12-10 ec201e2a6021 [PATCH 3/5] [ifcvt] optimize x=c ? (y AND z) : y by
RISC-V Zicond like insns
2023-12-10 5a4faf915575 [PATCH 2/5] [ifcvt] optimize x=c ? (y shift_op z):y by
RISC-V Zicond like insns
2023-12-07 9f7ad5eff3bf [PATCH 1/5][V3][ifcvt] optimize x=c ? (y op z) : y by
RISC-V Zicond like insns
Patch 2/5 even added tests to that effect:
e.g.
diff --git a/gcc/testsuite/gcc.target/riscv/zicond_ifcvt_opt.c
b/gcc/testsuite/gcc.target/riscv/zicond_ifcvt_opt.c
+long
+test_ShiftLeft_eqz (long x, long y, long z, long c)
+{
+ if (c)
+ x = y << z;
+ else
+ x = y;
+ return x;
+}
But weordly those tests don't codegen czero on trunk and even going back to
that commit itself (actually expected czero's wasn't bumped as part of that
change). So clearly something got lost or wasn't completely working.