Bug 109825 - [14 Regression] ICE in ix86_widen_mult_cost, at config/i386/i386.cc:20442 since r14-666-g608e7f3ab47fe7
Summary: [14 Regression] ICE in ix86_widen_mult_cost, at config/i386/i386.cc:20442 sin...
Status: RESOLVED DUPLICATE of bug 109807
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: 14.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2023-05-12 10:32 UTC by Martin Jambor
Modified: 2023-05-14 19:59 UTC (History)
3 users (show)

See Also:
Host: x86_64-linux
Target: x86_64-linux
Build:
Known to work:
Known to fail:
Last reconfirmed: 2023-05-13 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Jambor 2023-05-12 10:32:17 UTC
Compiling our gcc/testsuite/gcc.dg/vect/slp-widen-mult-u8.c with -Os
-ftree-slp-vectorize -mavx512vl (or -Oz, for that matter) leads to an
ICE:

/tmp$ ~/gcc/small/inst/bin/gcc -Os -ftree-slp-vectorize -mavx512vl ~/gcc/small/src/gcc/testsuite/gcc.dg/vect/slp-widen-mult-u8.c -S
during GIMPLE pass: slp
/home/mjambor/gcc/small/src/gcc/testsuite/gcc.dg/vect/slp-widen-mult-u8.c: In function ‘foo1’:
/home/mjambor/gcc/small/src/gcc/testsuite/gcc.dg/vect/slp-widen-mult-u8.c:15:1: internal compiler error: in ix86_widen_mult_cost, at config/i386/i386.cc:20442
   15 | foo1(int len) {
      | ^~~~
0x82f95a ix86_widen_mult_cost
        /home/mjambor/gcc/small/src/gcc/config/i386/i386.cc:20442
0x82f95a ix86_vector_costs::add_stmt_cost(int, vect_cost_for_stmt, _stmt_vec_info*, _slp_tree*, tree_node*, int, vect_cost_model_location)
        /home/mjambor/gcc/small/src/gcc/config/i386/i386.cc:23479
0x11fe9b2 add_stmt_cost(vector_costs*, int, vect_cost_for_stmt, _stmt_vec_info*, _slp_tree*, tree_node*, int, vect_cost_model_location)
        /home/mjambor/gcc/small/src/gcc/tree-vectorizer.h:1779
0x11fe9b2 add_stmt_cost(vector_costs*, stmt_info_for_cost*)
        /home/mjambor/gcc/small/src/gcc/tree-vectorizer.h:1801
0x11fe9b2 vect_bb_vectorization_profitable_p
        /home/mjambor/gcc/small/src/gcc/tree-vect-slp.cc:6928
0x1202f3e vect_slp_region
        /home/mjambor/gcc/small/src/gcc/tree-vect-slp.cc:7441
0x1203eec vect_slp_bbs
        /home/mjambor/gcc/small/src/gcc/tree-vect-slp.cc:7611
0x12041cc vect_slp_function(function*)
        /home/mjambor/gcc/small/src/gcc/tree-vect-slp.cc:7712
0x120e3d1 execute
        /home/mjambor/gcc/small/src/gcc/tree-vectorizer.cc:1529


I have bisected this to r14-666-g608e7f3ab47fe7:

commit 608e7f3ab47fe746279c552c3574147aa3d8ee76 (HEAD)
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Wed May 10 22:40:53 2023 +0200

    i386: Add missing vector extend patterns [PR92658]
    
    Add missing insn pattern for v2qi -> v2si vector extend and named
    expanders to activate generation of vector extends to 8-byte and 4-byte
    vectors.
    
    gcc/ChangeLog:
    
            PR target/92658
            * config/i386/mmx.md (sse4_1_<code>v2qiv2si2): New insn pattern.
            (<insn>v4qiv4hi2): New expander.
            (<insn>v2hiv2si2): Ditto.
            (<insn>v2qiv2si2): Ditto.
            (<insn>v2qiv2hi2): Ditto.
    
    gcc/testsuite/ChangeLog:
    
            PR target/92658
            * gcc.target/i386/pr92658-sse4-4b.c: New test.
            * gcc.target/i386/pr92658-sse4-8b.c: New test.
Comment 1 Richard Biener 2023-05-12 11:22:29 UTC
I think this was just fixed?
Comment 2 Uroš Bizjak 2023-05-12 11:35:18 UTC
(In reply to Richard Biener from comment #1)
> I think this was just fixed?

No, the asked mode is V2HImode, so it should also be added.
Comment 3 Uroš Bizjak 2023-05-12 11:40:26 UTC
(In reply to Uroš Bizjak from comment #2)
> (In reply to Richard Biener from comment #1)
> > I think this was just fixed?
> 
> No, the asked mode is V2HImode, so it should also be added.

OTOH, it is a bit strange to report some fake cost for unsupported modes. Should we return an arbitrary high value for unsupported modes instead of just ICEing?
Comment 4 Uroš Bizjak 2023-05-12 11:49:52 UTC
Like this:

--cut here--
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 62fe06fdbaa..e6091b8bd35 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -20417,14 +20417,12 @@ ix86_widen_mult_cost (const struct processor_costs *cost,
   int basic_cost = 0;
   switch (mode)
     {
-    case V4HImode:
     case V8HImode:
     case V16HImode:
       if (!uns_p || mode == V16HImode)
        extra_cost = cost->sse_op * 2;
       basic_cost = cost->mulss * 2 + cost->sse_op * 4;
       break;
-    case V2SImode:
     case V4SImode:
     case V8SImode:
       /* pmulhw/pmullw can be used.  */
@@ -20441,7 +20439,8 @@ ix86_widen_mult_cost (const struct processor_costs *cost,
       basic_cost = cost->mulss * 2 + cost->sse_op * 4;
       break;
     default:
-      gcc_unreachable();
+      /* Not implemented.  */
+      return 1000;
     }
   return ix86_vec_cost (mode, basic_cost + extra_cost);
 }
--cut here--
Comment 5 Andrew Pinski 2023-05-13 00:03:41 UTC
*** Bug 109838 has been marked as a duplicate of this bug. ***
Comment 6 Andrew Pinski 2023-05-13 00:06:43 UTC
.
Comment 7 Uroš Bizjak 2023-05-13 08:31:25 UTC
*** Bug 109807 has been marked as a duplicate of this bug. ***
Comment 8 Uroš Bizjak 2023-05-14 19:59:17 UTC
Dup.

*** This bug has been marked as a duplicate of bug 109807 ***