This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/15241] New: [tree-ssa] Convert a <= 7 && b <= 7 into (a | b) <= 7.


We should convert foo into bar (if profitable).

void baz ();

unsigned int
foo (unsigned int a, unsigned int b)
{
  if (a <= 7 && b <= 7)
    baz ();
}

unsigned int
bar (unsigned int a, unsigned int b)
{
  if ((a | b) <= 7)
    baz ();
}

The last SSA form looks like:

;; Function foo (foo)

foo (a, b)
{
  _Bool T.2;
  _Bool T.1;
  _Bool T.0;

<bb 0>:
  T.0_2 = a_1 <= 7;
  T.1_4 = b_3 <= 7;
  T.2_5 = T.0_2 && T.1_4;
  if (T.2_5) goto <L0>; else goto <L1>;

<L0>:;
  baz () [tail call];

<L1>:;
  return;

}



;; Function bar (bar)

bar (a, b)
{
  unsigned int T.3;

<bb 0>:
  T.3_3 = a_1 | b_2;
  if (T.3_3 <= 7) goto <L0>; else goto <L1>;

<L0>:;
  baz () [tail call];

<L1>:;
  return;

}

On i686-pc-linux-gnu, I get:

foo:
	cmpl	$7, 4(%esp)
	setbe	%dl
	cmpl	$7, 8(%esp)
	setbe	%al
	testb	%al, %dl
	jne	.L5
	rep ; ret
	.p2align 4,,7
.L5:
	jmp	baz
	.size	foo, .-foo
	.p2align 4,,15
.globl bar
	.type	bar, @function
bar:
	movl	8(%esp), %eax
	orl	4(%esp), %eax
	cmpl	$7, %eax
	jbe	.L9
	rep ; ret
	.p2align 4,,7
.L9:
	jmp	baz

-- 
           Summary: [tree-ssa] Convert a <= 7 && b <= 7 into (a | b) <= 7.
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Keywords: pessimizes-code
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15241


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]