https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106240
Bug ID: 106240 Summary: [13 Regression] Recent change causes missed vectorization opportunity on mips Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: law at gcc dot gnu.org Target Milestone: --- This can be see on the mipsisa32r2-linux-gnu target with a cross compiler. Starting a couple months ago these tests started failing on mipsisa32r2-linux-gnu: Tests that now fail, but worked before (24 tests): gcc.target/mips/mips-ps-5.c -O1 scan-assembler \tadd\\.ps\t gcc.target/mips/mips-ps-5.c -O1 scan-assembler \tc\\.eq\\.ps\t gcc.target/mips/mips-ps-5.c -O1 scan-assembler \tmov[tf]\\.ps\t gcc.target/mips/mips-ps-5.c -O2 scan-assembler \tadd\\.ps\t gcc.target/mips/mips-ps-5.c -O2 scan-assembler \tc\\.eq\\.ps\t gcc.target/mips/mips-ps-5.c -O2 scan-assembler \tmov[tf]\\.ps\t gcc.target/mips/mips-ps-5.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions scan-assembler \tadd\\.ps\t gcc.target/mips/mips-ps-5.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions scan-assembler \tc\\.eq\\.ps\t gcc.target/mips/mips-ps-5.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions scan-assembler \tmov[tf]\\.ps\t gcc.target/mips/mips-ps-5.c -O3 -g scan-assembler \tadd\\.ps\t gcc.target/mips/mips-ps-5.c -O3 -g scan-assembler \tc\\.eq\\.ps\t gcc.target/mips/mips-ps-5.c -O3 -g scan-assembler \tmov[tf]\\.ps\t gcc.target/mips/mips-ps-7.c -O1 scan-assembler \tadd\\.ps\t gcc.target/mips/mips-ps-7.c -O1 scan-assembler \tc\\.eq\\.ps\t gcc.target/mips/mips-ps-7.c -O1 scan-assembler \tmov[tf]\\.ps\t gcc.target/mips/mips-ps-7.c -O2 scan-assembler \tadd\\.ps\t gcc.target/mips/mips-ps-7.c -O2 scan-assembler \tc\\.eq\\.ps\t gcc.target/mips/mips-ps-7.c -O2 scan-assembler \tmov[tf]\\.ps\t gcc.target/mips/mips-ps-7.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions scan-assembler \tadd\\.ps\t gcc.target/mips/mips-ps-7.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions scan-assembler \tc\\.eq\\.ps\t gcc.target/mips/mips-ps-7.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions scan-assembler \tmov[tf]\\.ps\t gcc.target/mips/mips-ps-7.c -O3 -g scan-assembler \tadd\\.ps\t gcc.target/mips/mips-ps-7.c -O3 -g scan-assembler \tc\\.eq\\.ps\t gcc.target/mips/mips-ps-7.c -O3 -g scan-assembler \tmov[tf]\\.ps\t This change is the trigger: commit 68e0063397ba820e71adc220b2da0581dce29ffa Author: Richard Biener <rguent...@suse.de> Date: Mon Apr 11 13:36:53 2022 +0200 Force the selection operand of a GIMPLE COND_EXPR to be a register This goes away with the selection operand allowed to be a GENERIC tcc_comparison tree. It keeps those for vectorizer pattern recog, those are short lived and removing this instance is a bigger task. The patch doesn't yet remove dead code and functionality, that's left for a followup. Instead the patch makes sure to produce valid GIMPLE IL and continue to optimize COND_EXPRs where the previous IL allowed and the new IL showed regressions in the testsuite. [ ... ] Basically before this change we were able to vectorize the loop and after that change we no longer vectorize the loop. Testcase: /* { dg-do compile } */ /* { dg-options "-mpaired-single -mgp64 -ftree-vectorize forbid_cpu=octeon.*" } */ /* { dg-skip-if "requires vectorization" { *-*-* } { "-O0" "-Os" } { "" } } */ extern float a[] __attribute__ ((aligned (8))); extern float b[] __attribute__ ((aligned (8))); extern float c[] __attribute__ ((aligned (8))); NOMIPS16 void foo (void) { int i; for (i = 0; i < 16; i++) a[i] = b[i] == c[i] + 1 ? b[i] : c[i]; } /* { dg-final { scan-assembler "\tadd\\.ps\t" } } */ /* { dg-final { scan-assembler "\tc\\.eq\\.ps\t" } } */ /* { dg-final { scan-assembler "\tmov\[tf\]\\.ps\t" } } */ Compilation line: /home/jlaw/test/obj/mipsisa32r2-linux-gnu/obj/gcc/gcc/xgcc -B/home/jlaw/test/obj/mipsisa32r2-linux-gnu/obj/gcc/gcc/ /home/jlaw/test/gcc/gcc/testsuite/gcc.target/mips/mips-ps-5.c -fdiagnostics-plain-output -O2 -DNOMIPS16="__attribute__((nomips16))" -DNOMICROMIPS="__attribute__((nomicromips))" -DNOCOMPRESSION="__attribute__((nocompression))" -mabi=o64 -mips64r2 -mhard-float -mdouble-float -mfp64 -mgp64 -mlong32 -mpaired-single -modd-spreg -ftree-vectorize -fno-ident -S -o mips-ps-5.s -fdump-tree-all-details As one would expect this patch changes the form of the COND_EXPRs and ultimately we're unable to vectorize as a result. I haven't dug any deeper than that.