On Sat, Jan 6, 2024 at 2:30 PM Roger Sayle <ro...@nextmovesoftware.com> wrote: > > > This patch improves the cost/gain calculation used during the i386 backend's > SImode/DImode scalar-to-vector (STV) conversion pass. The current code > handles loads and stores, but doesn't consider that converting other > scalar operations with a memory destination, requires an explicit load > before and an explicit store after the vector equivalent. > > To ease the review, the significant change looks like: > > /* For operations on memory operands, include the overhead > of explicit load and store instructions. */ > if (MEM_P (dst)) > igain += !optimize_insn_for_size_p () > ? (m * (ix86_cost->int_load[2] > + ix86_cost->int_store[2]) > - (ix86_cost->sse_load[sse_cost_idx] + > ix86_cost->sse_store[sse_cost_idx])) > : -COSTS_N_BYTES (8);
Please just swap true and false statements to avoid negative test. > however the patch itself is complicated by a change in indentation > which leads to a number of lines with only whitespace changes. 'git diff -w' to the rescue ;) > For architectures where integer load/store costs are the same as > vector load/store costs, there should be no change without -Os/-Oz. > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check, both with and without --target_board=unix{-m32} > with no new failures. Ok for mainline? > > > 2024-01-06 Roger Sayle <ro...@nextmovesoftware.com> > > gcc/ChangeLog > PR target/113231 > * config/i386/i386-features.cc (compute_convert_gain): Include > the overhead of explicit load and store (movd) instructions when > converting non-store scalar operations with memory destinations. > > gcc/testsuite/ChangeLog > PR target/113231 > * gcc.target/i386/pr113231.c: New test case. OK with the above proposed change. Thanks, Uros.