From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id 5FDC13858C3A for ; Mon, 27 Sep 2021 16:40:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5FDC13858C3A Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mUtfd-0009Jt-NJ for gcc-help@gcc.gnu.org; Mon, 27 Sep 2021 18:40:01 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-help@gcc.gnu.org From: Dave Love Subject: Does -floop-nest-optimize ever work usefully? Date: Mon, 27 Sep 2021 17:01:26 +0100 Message-ID: <87bl4ehusp.fsf@albion.it.manchester.ac.uk> Mime-Version: 1.0 Content-Type: text/plain User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cancel-Lock: sha1:6VKzuzPyLBWY4IlWVCF14KYf1T4= X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Sep 2021 16:40:05 -0000 [I don't know if this merits a bug report, but I expect there's something worth understanding anyway.] I'd like to have polyhedral-type optimizations available, but I've never been able to get -floop-nest-optimize to do anything useful with various GCC releases. (I realize it's always been marked experimental.) Does it ever actually do anything other than pessimize loop nests, at least due to stopping vectorization? If so, what's the trick? For instance, consider the matmul (dgemm) example from Pluto : for (i = 0; i < M; i++) for (j = 0; j < N; j++) for (k = 0; k < K; k++) C[i][j] = beta * C[i][j] + alpha * A[i][k] * B[k][j]; If I use -Ofast -floop-nest-optimize, graphite fails: matmul.c:73:42: missed: failed: evolution of offset is not affine. but there's a drastic pessimization (compared with just -Ofast): matmul.c:73:42: missed: couldn't vectorize loop With -O2 -ffast-math -ftree-loop-vectorize -floop-nest-optimize it does report the nest was optimized, but still vectorization fails, with an extra message: matmul.c:73:42: missed: not vectorized: no vectype for stmt: _17 = A[_62][_61]; The above is on SKX with GCC 11, with or without -march=native. On ppc64le, -floop-nest-optimize didn't seem to kick in. The results with pluto+gcc, or clang with polly, are much better than gcc -Ofast -- they generate a five-level loop nest, with default tiling. (I tried with xlc on ppc64le, and couldn't find a way to stop it pattern-matching to call external dgemm...) Thanks for any insight.