~pali/+junk/llvm-toolchain-3.7

« back to all changes in this revision

Viewing changes to test/Transforms/InstCombine/logical-select.ll

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2015-07-15 17:51:08 UTC
  • Revision ID: package-import@ubuntu.com-20150715175108-l8mynwovkx4zx697
Tags: upstream-3.7~+rc2
ImportĀ upstreamĀ versionĀ 3.7~+rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
; RUN: opt < %s -instcombine -S | FileCheck %s
 
2
 
 
3
 
 
4
define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d) nounwind {
 
5
  %e = icmp slt i32 %a, %b
 
6
  %f = sext i1 %e to i32
 
7
  %g = and i32 %c, %f
 
8
  %h = xor i32 %f, -1
 
9
  %i = and i32 %d, %h
 
10
  %j = or i32 %g, %i
 
11
  ret i32 %j
 
12
; CHECK: %e = icmp slt i32 %a, %b
 
13
; CHECK-NEXT: [[result:%.*]] = select i1 %e, i32 %c, i32 %d
 
14
; CHECK-NEXT: ret i32 [[result]]
 
15
}
 
16
define i32 @bar(i32 %a, i32 %b, i32 %c, i32 %d) nounwind {
 
17
  %e = icmp slt i32 %a, %b
 
18
  %f = sext i1 %e to i32
 
19
  %g = and i32 %c, %f
 
20
  %h = xor i32 %f, -1
 
21
  %i = and i32 %d, %h
 
22
  %j = or i32 %i, %g
 
23
  ret i32 %j
 
24
; CHECK: %e = icmp slt i32 %a, %b
 
25
; CHECK-NEXT: [[result:%.*]] = select i1 %e, i32 %c, i32 %d
 
26
; CHECK-NEXT: ret i32 [[result]]
 
27
}
 
28
 
 
29
define i32 @goo(i32 %a, i32 %b, i32 %c, i32 %d) nounwind {
 
30
entry:
 
31
  %0 = icmp slt i32 %a, %b
 
32
  %iftmp.0.0 = select i1 %0, i32 -1, i32 0
 
33
  %1 = and i32 %iftmp.0.0, %c
 
34
  %not = xor i32 %iftmp.0.0, -1
 
35
  %2 = and i32 %not, %d
 
36
  %3 = or i32 %1, %2
 
37
  ret i32 %3
 
38
; CHECK: %0 = icmp slt i32 %a, %b
 
39
; CHECK-NEXT: [[result:%.*]] = select i1 %0, i32 %c, i32 %d
 
40
; CHECK-NEXT: ret i32 [[result]]
 
41
}
 
42
define i32 @poo(i32 %a, i32 %b, i32 %c, i32 %d) nounwind {
 
43
entry:
 
44
  %0 = icmp slt i32 %a, %b
 
45
  %iftmp.0.0 = select i1 %0, i32 -1, i32 0
 
46
  %1 = and i32 %iftmp.0.0, %c
 
47
  %iftmp = select i1 %0, i32 0, i32 -1
 
48
  %2 = and i32 %iftmp, %d
 
49
  %3 = or i32 %1, %2
 
50
  ret i32 %3
 
51
; CHECK: %0 = icmp slt i32 %a, %b
 
52
; CHECK-NEXT: [[result:%.*]] = select i1 %0, i32 %c, i32 %d
 
53
; CHECK-NEXT: ret i32 [[result]]
 
54
}
 
55
 
 
56
define i32 @par(i32 %a, i32 %b, i32 %c, i32 %d) nounwind {
 
57
entry:
 
58
  %0 = icmp slt i32 %a, %b
 
59
  %iftmp.1.0 = select i1 %0, i32 -1, i32 0
 
60
  %1 = and i32 %iftmp.1.0, %c
 
61
  %not = xor i32 %iftmp.1.0, -1
 
62
  %2 = and i32 %not, %d
 
63
  %3 = or i32 %1, %2
 
64
  ret i32 %3
 
65
; CHECK: %0 = icmp slt i32 %a, %b
 
66
; CHECK-NEXT: [[result:%.*]] = select i1 %0, i32 %c, i32 %d
 
67
; CHECK-NEXT: ret i32 [[result]]
 
68
}