On 2025-11-21 11:29, Jakub Jelinek wrote:
On Thu, Nov 20, 2025 at 09:33:50AM +0530, Dhruv Chawla wrote:
Thanks, I have attached the updated patch.

        PR tree-optimization/122733

gcc/ChangeLog:

        * match.pd ((y << x) {<,<=,>,>=} x): Remove.
        ((y << x) {==,!=} x): Call constant_boolean_node instead of
        build_one_cst/build_zero_cst and combine into one pattern.

gcc/testsuite/ChangeLog:

        * gcc.dg/match-shift-cmp-1.c: Update test to only check
        equality.
        * gcc.dg/match-shift-cmp-2.c: Likewise.
        * gcc.dg/match-shift-cmp-3.c: Likewise.
        * gcc.dg/match-shift-cmp-4.c: Removed.

LGTM.

        Jakub



The change introduced to match-shift-cmp-3.c fails for arm-none-eabi:

Testing gcc.dg/match-shift-cmp-3.c
doing compile
Executing on host: /build/r16-7687-g772499fd7e2f9a/bin/arm-none-eabi-gcc  
/build/gcc_src/gcc/testsuite/gcc.dg/match-shift-cmp-3.c  -mthumb 
-march=armv6s-m -mtune=cortex-m0 -mfloat-abi=soft -mfpu=auto   
-fdiagnostics-plain-output   -O2 -fdump-tree-optimized -S     -o 
match-shift-cmp-3.s    (timeout = 800)
spawn -ignore SIGHUP /build/r16-7687-g772499fd7e2f9a/bin/arm-none-eabi-gcc 
/build/gcc_src/gcc/testsuite/gcc.dg/match-shift-cmp-3.c -mthumb -march=armv6s-m 
-mtune=cortex-m0 -mfloat-abi=soft -mfpu=auto -fdiagnostics-plain-output -O2 
-fdump-tree-optimized -S -o match-shift-cmp-3.s
pid is 70634 -70634
pid is -1
output is  status 0
PASS: gcc.dg/match-shift-cmp-3.c (test for excess errors)
gcc.dg/match-shift-cmp-3.c: pattern found 4 times
FAIL: gcc.dg/match-shift-cmp-3.c scan-tree-dump-times optimized "return 0;" 6
gcc.dg/match-shift-cmp-3.c: pattern found 4 times
FAIL: gcc.dg/match-shift-cmp-3.c scan-tree-dump-times optimized "return 1;" 6


I've checked that this also happens in r16-5648-g862d4309dcb342, where the 
change was introduced.
Is it expected that the test have different number of patterns depending on the 
target?

Running the same test on x86_64-pc-linux-gnu (r16-7687-g772499fd7e2f9a) pass'es.

Kind regards,
Torbjörn

Reply via email to