This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PR34959: (was Re: RFA: Fix modes in ctz libcall notes)
Richard Sandiford <rsandifo@nildram.co.uk> writes:
> I agree we should use canonical forms, and since it doesn't make any
> difference for MIPS, I'm happy to do that in isolation. Is the patch
> below OK, if it survives testing?
Now bootstrapped & regression-tested on x86_64-linux-gnu and
regression-tested on both mips64-linux-gnu and mipsisa64-elf.
OK to install?
Richard
gcc/
PR rtl-optimization/34959
* optabs.c (expand_unop): In libcall notes, give ffs, clz, ctz,
popcount and parity rtxes the same mode as their operand.
Truncate or extend the result to the return value's mode
if necessary.
Index: gcc/optabs.c
===================================================================
--- gcc/optabs.c 2008-01-26 09:23:24.000000000 +0000
+++ gcc/optabs.c 2008-01-26 10:53:12.000000000 +0000
@@ -3273,6 +3273,7 @@ expand_unop (enum machine_mode mode, opt
{
rtx insns;
rtx value;
+ rtx eq_value;
enum machine_mode outmode = mode;
/* All of these functions return small values. Thus we choose to
@@ -3292,8 +3293,12 @@ expand_unop (enum machine_mode mode, opt
end_sequence ();
target = gen_reg_rtx (outmode);
- emit_libcall_block (insns, target, value,
- gen_rtx_fmt_e (unoptab->code, outmode, op0));
+ eq_value = gen_rtx_fmt_e (unoptab->code, mode, op0);
+ if (GET_MODE_SIZE (outmode) < GET_MODE_SIZE (mode))
+ eq_value = simplify_gen_unary (TRUNCATE, outmode, eq_value, mode);
+ else if (GET_MODE_SIZE (outmode) > GET_MODE_SIZE (mode))
+ eq_value = simplify_gen_unary (ZERO_EXTEND, outmode, eq_value, mode);
+ emit_libcall_block (insns, target, value, eq_value);
return target;
}