public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed][RISC-V]Don't reject constants in cmov condition
@ 2023-08-07 20:36 Jeff Law
  2023-08-07 23:42 ` Vineet Gupta
  2023-08-08 17:21 ` RV64 Zicond ICE (was Re: [committed][RISC-V]Don't reject constants in cmov condition) Vineet Gupta
  0 siblings, 2 replies; 6+ messages in thread
From: Jeff Law @ 2023-08-07 20:36 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 214 bytes --]


This test is too aggressive.  Constants have VOIDmode, so we need to let 
the through this phase of conditional move support.

Fixes several missed conditional moves with the trunk.

Committed to the trunk,

Jeff

[-- Attachment #2: P --]
[-- Type: text/plain, Size: 1304 bytes --]

commit 18c453f0e633abb9b317947b011ec6e07780fba8
Author: Jeff Law <jlaw@ventanamicro.com>
Date:   Mon Aug 7 14:34:40 2023 -0600

    [committed][RISC-V]Don't reject constants in cmov condition
    
    This test is too aggressive.  Constants have VOIDmode, so we need to let the
    through this phase of conditional move support.
    
    Fixes several missed conditional moves with the trunk.
    
    gcc/
            * config/riscv/riscv.cc (riscv_expand_conditional_move): Allow
            VOIDmode operands to conditional before canonicalization.

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 279304afc19..5248dd3febe 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -3582,7 +3582,8 @@ riscv_expand_conditional_move (rtx dest, rtx op, rtx cons, rtx alt)
 	 enforce that so that we don't strip away a sign_extension
 	 thinking it is unnecessary.  We might consider using
 	 riscv_extend_operands if they are not already properly extended.  */
-      if (GET_MODE (op0) != word_mode || GET_MODE (op1) != word_mode)
+      if ((GET_MODE (op0) != word_mode && GET_MODE (op0) != VOIDmode)
+	  || (GET_MODE (op1) != word_mode && GET_MODE (op1) != VOIDmode))
 	return false;
 
       /* Canonicalize the comparison.  It must be an equality comparison

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [committed][RISC-V]Don't reject constants in cmov condition
  2023-08-07 20:36 [committed][RISC-V]Don't reject constants in cmov condition Jeff Law
@ 2023-08-07 23:42 ` Vineet Gupta
  2023-08-08 14:27   ` Jeff Law
  2023-08-08 17:21 ` RV64 Zicond ICE (was Re: [committed][RISC-V]Don't reject constants in cmov condition) Vineet Gupta
  1 sibling, 1 reply; 6+ messages in thread
From: Vineet Gupta @ 2023-08-07 23:42 UTC (permalink / raw)
  To: Jeff Law, gcc-patches


On 8/7/23 13:36, Jeff Law wrote:
> Fixes several missed conditional moves with the trunk. 

I'm curious, how do you know what's missing. Does ifc have some stats 
like autovec which explicitly reports missed opportunities ?

-Vineet

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [committed][RISC-V]Don't reject constants in cmov condition
  2023-08-07 23:42 ` Vineet Gupta
@ 2023-08-08 14:27   ` Jeff Law
  0 siblings, 0 replies; 6+ messages in thread
From: Jeff Law @ 2023-08-08 14:27 UTC (permalink / raw)
  To: gcc-patches



On 8/7/23 17:42, Vineet Gupta wrote:
> 
> On 8/7/23 13:36, Jeff Law wrote:
>> Fixes several missed conditional moves with the trunk. 
> 
> I'm curious, how do you know what's missing. Does ifc have some stats 
> like autovec which explicitly reports missed opportunities ?
Xiao's testcases :-)

I haven't even got to the point of trying our internal ones. yet.
jeff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RV64 Zicond ICE (was Re: [committed][RISC-V]Don't reject constants in cmov condition)
  2023-08-07 20:36 [committed][RISC-V]Don't reject constants in cmov condition Jeff Law
  2023-08-07 23:42 ` Vineet Gupta
@ 2023-08-08 17:21 ` Vineet Gupta
  2023-08-08 17:46   ` Jeff Law
  2023-08-08 21:41   ` Jeff Law
  1 sibling, 2 replies; 6+ messages in thread
From: Vineet Gupta @ 2023-08-08 17:21 UTC (permalink / raw)
  To: Jeff Law, gcc-patches

Hi Jeff,

On 8/7/23 13:36, Jeff Law wrote:
>
> This test is too aggressive.  Constants have VOIDmode, so we need to 
> let the through this phase of conditional move support.
>
> Fixes several missed conditional moves with the trunk.
>
> Committed to the trunk,

As discussed this morning, this triggers an ICE when building glibc for 
rv64_zicond

programs/ld-ctype.c:3977:1: error: unrecognizable insn:
  3977 | }
       | ^
(insn 238 237 239 18 (set (reg:SI 727)
         (if_then_else:SI (eq:SI (reg:SI 725)
                 (const_int 0 [0]))
             (const_int 0 [0])
             (reg:SI 721))) -1
      (nil))
during RTL pass: vregs
programs/ld-ctype.c:3977:1: internal compiler error: in extract_insn, at 
recog.cc:2791
0x885de7 _fatal_insn(char const*, rtx_def const*, char const*, int, char 
const*)     ../.././gcc/gcc/rtl-error.cc:108
0x885e09 _fatal_insn_not_found(rtx_def const*, char const*, int, char 
const*)    ../.././gcc/gcc/rtl-error.cc:116
0x8846f9 extract_insn(rtx_insn*)    ../.././gcc/gcc/recog.cc:2791
0xcf77ae instantiate_virtual_regs_in_insn ../.././gcc/gcc/function.cc:1610
0xcf77ae instantiate_virtual_regs ../.././gcc/gcc/function.cc:1983
0xcf77ae execute    ../.././gcc/gcc/function.cc:2030

Here's the reduced reproducer.

a, c;
long b;
d() {
   for (;;)
     if (a & (b < 8 ?: 1 << b))
       c = 1;
}

I'll try to muster a fix :-)

Thx,
-Vineet

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RV64 Zicond ICE (was Re: [committed][RISC-V]Don't reject constants in cmov condition)
  2023-08-08 17:21 ` RV64 Zicond ICE (was Re: [committed][RISC-V]Don't reject constants in cmov condition) Vineet Gupta
@ 2023-08-08 17:46   ` Jeff Law
  2023-08-08 21:41   ` Jeff Law
  1 sibling, 0 replies; 6+ messages in thread
From: Jeff Law @ 2023-08-08 17:46 UTC (permalink / raw)
  To: Vineet Gupta, Jeff Law, gcc-patches



On 8/8/23 11:21, Vineet Gupta wrote:
> Hi Jeff,
> 
> On 8/7/23 13:36, Jeff Law wrote:
>>
>> This test is too aggressive.  Constants have VOIDmode, so we need to 
>> let the through this phase of conditional move support.
>>
>> Fixes several missed conditional moves with the trunk.
>>
>> Committed to the trunk,
> 
> As discussed this morning, this triggers an ICE when building glibc for 
> rv64_zicond
> 
> programs/ld-ctype.c:3977:1: error: unrecognizable insn:
>   3977 | }
>        | ^
> (insn 238 237 239 18 (set (reg:SI 727)
>          (if_then_else:SI (eq:SI (reg:SI 725)
>                  (const_int 0 [0]))
>              (const_int 0 [0])
>              (reg:SI 721))) -1
>       (nil))
> during RTL pass: vregs
> programs/ld-ctype.c:3977:1: internal compiler error: in extract_insn, at 
> recog.cc:2791
> 0x885de7 _fatal_insn(char const*, rtx_def const*, char const*, int, char 
> const*)     ../.././gcc/gcc/rtl-error.cc:108
> 0x885e09 _fatal_insn_not_found(rtx_def const*, char const*, int, char 
> const*)    ../.././gcc/gcc/rtl-error.cc:116
> 0x8846f9 extract_insn(rtx_insn*)    ../.././gcc/gcc/recog.cc:2791
> 0xcf77ae instantiate_virtual_regs_in_insn ../.././gcc/gcc/function.cc:1610
> 0xcf77ae instantiate_virtual_regs ../.././gcc/gcc/function.cc:1983
> 0xcf77ae execute    ../.././gcc/gcc/function.cc:2030
> 
> Here's the reduced reproducer.
> 
> a, c;
> long b;
> d() {
>    for (;;)
>      if (a & (b < 8 ?: 1 << b))
>        c = 1;
> }
> 
> I'll try to muster a fix :-)
:-)  That's even simpler than the one I just reduced.  But I can see the 
same basic structure in my reduced case.

I'll take it from here.  I mucked something up, so I feel I ought to fix it.

jeff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RV64 Zicond ICE (was Re: [committed][RISC-V]Don't reject constants in cmov condition)
  2023-08-08 17:21 ` RV64 Zicond ICE (was Re: [committed][RISC-V]Don't reject constants in cmov condition) Vineet Gupta
  2023-08-08 17:46   ` Jeff Law
@ 2023-08-08 21:41   ` Jeff Law
  1 sibling, 0 replies; 6+ messages in thread
From: Jeff Law @ 2023-08-08 21:41 UTC (permalink / raw)
  To: Vineet Gupta, Jeff Law, gcc-patches



On 8/8/23 11:21, Vineet Gupta wrote:
> Hi Jeff,
> 
> On 8/7/23 13:36, Jeff Law wrote:
>>
>> This test is too aggressive.  Constants have VOIDmode, so we need to 
>> let the through this phase of conditional move support.
>>
>> Fixes several missed conditional moves with the trunk.
>>
>> Committed to the trunk,
> 
> As discussed this morning, this triggers an ICE when building glibc for 
> rv64_zicond
> 
> programs/ld-ctype.c:3977:1: error: unrecognizable insn:
>   3977 | }
>        | ^
> (insn 238 237 239 18 (set (reg:SI 727)
>          (if_then_else:SI (eq:SI (reg:SI 725)
>                  (const_int 0 [0]))
>              (const_int 0 [0])
>              (reg:SI 721))) -1
>       (nil))
> during RTL pass: vregs
> programs/ld-ctype.c:3977:1: internal compiler error: in extract_insn, at 
> recog.cc:2791
> 0x885de7 _fatal_insn(char const*, rtx_def const*, char const*, int, char 
> const*)     ../.././gcc/gcc/rtl-error.cc:108
> 0x885e09 _fatal_insn_not_found(rtx_def const*, char const*, int, char 
> const*)    ../.././gcc/gcc/rtl-error.cc:116
> 0x8846f9 extract_insn(rtx_insn*)    ../.././gcc/gcc/recog.cc:2791
> 0xcf77ae instantiate_virtual_regs_in_insn ../.././gcc/gcc/function.cc:1610
> 0xcf77ae instantiate_virtual_regs ../.././gcc/gcc/function.cc:1983
> 0xcf77ae execute    ../.././gcc/gcc/function.cc:2030
> 
> Here's the reduced reproducer.
> 
> a, c;
> long b;
> d() {
>    for (;;)
>      if (a & (b < 8 ?: 1 << b))
>        c = 1;
> }
> 
> I'll try to muster a fix :-)
Should be fixed now, with a regression test in the suite.

Thanks,
jeff

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-08 21:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 20:36 [committed][RISC-V]Don't reject constants in cmov condition Jeff Law
2023-08-07 23:42 ` Vineet Gupta
2023-08-08 14:27   ` Jeff Law
2023-08-08 17:21 ` RV64 Zicond ICE (was Re: [committed][RISC-V]Don't reject constants in cmov condition) Vineet Gupta
2023-08-08 17:46   ` Jeff Law
2023-08-08 21:41   ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).