• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -march=x86 -mcpu=yonah | FileCheck %s
2; rdar://5752025
3
4; We want:
5;      CHECK: movl	4(%esp), %ecx
6; CHECK-NEXT: andl	$15, %ecx
7; CHECK-NEXT: movl	$42, %eax
8; CHECK-NEXT: cmovel	%ecx, %eax
9; CHECK-NEXT: ret
10;
11; We don't want:
12;	movl	4(%esp), %eax
13;	movl	%eax, %ecx     # bad: extra copy
14;	andl	$15, %ecx
15;	testl	$15, %eax      # bad: peep obstructed
16;	movl	$42, %eax
17;	cmovel	%ecx, %eax
18;	ret
19;
20; We also don't want:
21;	movl	$15, %ecx      # bad: larger encoding
22;	andl	4(%esp), %ecx
23;	movl	$42, %eax
24;	cmovel	%ecx, %eax
25;	ret
26;
27; We also don't want:
28;	movl	4(%esp), %ecx
29;	andl	$15, %ecx
30;	testl	%ecx, %ecx     # bad: unnecessary test
31;	movl	$42, %eax
32;	cmovel	%ecx, %eax
33;	ret
34
35define i32 @t1(i32 %X) nounwind  {
36entry:
37	%tmp2 = and i32 %X, 15		; <i32> [#uses=2]
38	%tmp4 = icmp eq i32 %tmp2, 0		; <i1> [#uses=1]
39	%retval = select i1 %tmp4, i32 %tmp2, i32 42		; <i32> [#uses=1]
40	ret i32 %retval
41}
42