+++ This bug was initially created as a clone of Bug #20517 +++ From comment #4: ----- testcase.c ----- _Bool foo(unsigned i) { return (i >> 5) > 10; } _Bool bar(unsigned i) { return i > (10 << 5) + 31; } int fooi(unsigned i) { return (i >> 5) > 10; } int bari(unsigned i) { return i > (10 << 5) + 31; } ---------------------- Compiled with: $ gcc-4.6.0-pre9999 tst6.c -O3 -S -m32 -fomit-frame-pointer (svn r162190) Results in: foo: movl 4(%esp), %eax shrl $5, %eax cmpl $10, %eax seta %al ret bar: cmpl $351, 4(%esp) seta %al ret fooi: movl 4(%esp), %eax shrl $5, %eax cmpl $10, %eax seta %al movzbl %al, %eax ret bari: xorl %eax, %eax cmpl $351, 4(%esp) seta %al ret
Created attachment 21756 [details] Jakub's patch from PR20517 comment #6 gcc bootstrapped fine The resulting code for foo() and fooi() is the same as for bar() and bari(), respectively.
Subject: Bug 45617 Author: jakub Date: Mon Sep 13 21:00:03 2010 New Revision: 164257 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=164257 Log: PR rtl-optimization/45617 * combine.c (simplify_comparison): Optimize (X >> N) {>,>=,<,<=} C even if low N bits of X aren't known to be zero. * gcc.target/i386/pr45617.c: New test. Added: trunk/gcc/testsuite/gcc.target/i386/pr45617.c Modified: trunk/gcc/ChangeLog trunk/gcc/combine.c trunk/gcc/testsuite/ChangeLog
Committed.