x86_cse: Add a Test for PR target/125245
A new test case is added to verify the fix for PR target/125245, which involves checking CONST0_RTX and CONSTM1_RTX in the x86 common subexpression elimination…
This commit adds a new test case to verify the fix for PR target/125245. The bug involved the x86 common subexpression elimination (CSE) pass not correctly handling CONST0_RTX and CONSTM1_RTX when dealing with constant vectors. The new test ensures that redundant vector loads are properly replaced, leading to more efficient code generation.
In Details
This patch adds gcc.target/i386/pr125245.c to test the fix in commit 7d84a357cfaa3d9ff2cc600a3c145780d37b6aed. That commit adjusted ix86_place_single_vector_set and ix86_broadcast_inner in i386-features.cc to handle CONST0_RTX and CONSTM1_RTX during vectorization. Common subexpression elimination (CSE) is a standard compiler optimization, but the x86 backend has its own quirks in config/i386/i386-features.cc.
For Context
Common subexpression elimination (CSE) is a compiler optimization that identifies and removes redundant calculations. In the x86 backend of GCC, this optimization needs to be aware of specific constants like CONST0_RTX (zero) and CONSTM1_RTX (minus one) when dealing with vector operations. This commit adds a test case to ensure that the CSE pass correctly handles these constants, leading to more efficient code by avoiding unnecessary recalculations.