This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH PR68542]
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: Yuri Rumyantsev <ysrumyan at gmail dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>, Igor Zamyatin <izamyatin at gmail dot com>, Kirill Yukhin <kirill dot Yukhin at gmail dot com>
- Date: Thu, 28 Jan 2016 15:24:31 +0100
- Subject: Re: [PATCH PR68542]
- Authentication-results: sourceware.org; auth=none
- References: <CAEoMCqQT9xxV-1sZPEQPfbuVrTvCVsCyWc4pEbiuph_tXMMqFw at mail dot gmail dot com> <CAFiYyc1BRb0-u5mmzT-M6PJk1JUVKLxJHMCJYoxi3f9ABjNhBw at mail dot gmail dot com> <CAEoMCqTV297wcT9D=0M0oG4MryMoG9iU9563BRA=9LHza46xMA at mail dot gmail dot com> <CAFiYyc0Kip21M=rLOZZ2=wAMdXCKAsw1KVJQEW5JZ+-CS4BXUw at mail dot gmail dot com> <CAEoMCqQ9mJUvVsiGLE-ay0iS17Qn-BP2BX8DSLfzAwUqW_Jgtg at mail dot gmail dot com> <CAFiYyc0hTOC74FpjeZuruOuwDZQzXua2xiGjSLCJNJ8XphGmDQ at mail dot gmail dot com> <CAEoMCqRcLz2_X1yZdSzEbxequR0CPMmmX=8UkgyMoZi5_XLoRg at mail dot gmail dot com> <CAEoMCqQshpeSPCRQLQXRY74oMNqq+FoL4L0iAsZRWEKQ__Fcsg at mail dot gmail dot com> <CAFiYyc2Vy7+_9epN8POs7ZU9A3CYYmtpMwZ-2C+F6d=nn_Kx4w at mail dot gmail dot com> <CAEoMCqRhaFMKeKch58PPZ0EgGW_7PGm7WsUVBYnTqnfAfQ7_Pw at mail dot gmail dot com> <CAFiYyc2g7jPKYeTd=8DTjDdsf7ND1jdjn4ZwH2u1MeNzPHea0Q at mail dot gmail dot com> <CAEoMCqR5BoWWPa3YrrFanHX7Lxv72_2UrQzZv3YkJsbuYd+v3g at mail dot gmail dot com> <CAFiYyc0kH_f0Le8k3VpvVF9br5io+nmzBPi+JtieOOE8AfP0Vw at mail dot gmail dot com> <CAEoMCqSbNAZkTA-pJcuyce7=BotmGEBuMhWvHTqvNAn8kmDggw at mail dot gmail dot com> <CAFiYyc1GYRCwGnpkVNyqSmGBm-mf818Ro0FpurMJCyVnwg7kXw at mail dot gmail dot com> <CAEoMCqTMVbb5c5cTLg=_NUN=VHaO=E=ehK+N0VuCX0_e8p4V8g at mail dot gmail dot com>
On Thu, Jan 28, 2016 at 2:37 PM, Yuri Rumyantsev <ysrumyan@gmail.com> wrote:
> Thanks Richard.
>
> Uros,
>
> Could you please review back-end part of this patch?
No problem, but please in future CC me on the x86 patches, so I won't forgot.
+(define_expand "cbranch<mode>4"
+ [(set (reg:CC FLAGS_REG)
+ (compare:CC (match_operand:V48_AVX2 1 "nonimmediate_operand")
+ (match_operand:V48_AVX2 2 "register_operand")))
+
Please swap predicates, operand 1 should be register_operand and
operand 2 nonimmediate operand.
+ (set (pc) (if_then_else
+ (match_operator 0 "bt_comparison_operator"
+ [(reg:CC FLAGS_REG) (const_int 0)])
+ (label_ref (match_operand 3))
+ (pc)))]
+ "TARGET_AVX2"
PTEST was introduced with SSE4_1, I see no reason to limit this
transformation to AVX2. However, since you check MODE_VECTOR_INT in
the expander, it looks that the pattern should only handle integer
modes.
+ /* Handle special case - vector comparsion with boolean result, transform
+ it using ptest instruction. */
+ if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
+ {
+ rtx lhs;
No need for the above variable, we will use tmp here.
+ rtx flag;
+ machine_mode p_mode = GET_MODE_SIZE (mode) == 32 ? V4DImode : V2DImode;
space here.
+ gcc_assert (code == EQ || code == NE);
+ if (!REG_P (op0))
+ op0 = force_reg (mode, op0);
+ if (!REG_P (op1))
+ op1 = force_reg (mode, op1);
No need for the above fixups, predicates already did the job.
+ /* Generate subtraction since we can't check that one operand is
+ zero vector. */
+ lhs = gen_reg_rtx (mode);
tmp = ...
+ emit_insn (gen_rtx_SET (lhs, gen_rtx_MINUS (mode, op0, op1)));
Since we are only interested in equality, should we rather use XOR,
since it is commutative operator.
+ lhs = gen_rtx_SUBREG (p_mode, lhs, 0);
tmp = gen_lowpart (p_mode, tmp);
+ tmp = gen_rtx_SET (gen_rtx_REG (CCmode, FLAGS_REG),
+ gen_rtx_UNSPEC (CCmode,
+ gen_rtvec (2, lhs, lhs),
+ UNSPEC_PTEST));
+ emit_insn (tmp);
There is no need for a temporary here, just use
emit_insn (gen_rtx_SET ( ... ) ...
+ tmp = gen_rtx_fmt_ee (code, VOIDmode, flag, const0_rtx);
+ if (code == EQ)
+ tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
+ gen_rtx_LABEL_REF (VOIDmode, label), pc_rtx);
+ else
+ tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
+ pc_rtx, gen_rtx_LABEL_REF (VOIDmode, label));
+ emit_jump_insn (gen_rtx_SET (pc_rtx, tmp));
+ return;
Oh.... please use something involving std::swap here.
Uros.