aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/Transforms/SCCP/overdefined-ext.ll
blob: 217daa750cc1da194d98ed58a128153ced05b7d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=sccp -S | FileCheck %s

define i32 @zext_lshr(i1 %t0) {
; CHECK-LABEL: @zext_lshr(
; CHECK-NEXT:    [[T1:%.*]] = zext i1 [[T0:%.*]] to i32
; CHECK-NEXT:    ret i32 0
;
  %t1 = zext i1 %t0 to i32
  %t2 = lshr i32 %t1, 1
  ret i32 %t2
}

define i1 @zext_icmp(i1 %t0) {
; CHECK-LABEL: @zext_icmp(
; CHECK-NEXT:    [[T1:%.*]] = zext i1 [[T0:%.*]] to i32
; CHECK-NEXT:    ret i1 false
;
  %t1 = zext i1 %t0 to i32
  %t2 = icmp eq i32 %t1, 2
  ret i1 %t2
}

; negative test. SCCP operates poorly with vector ranges

define <2 x i1> @zext_vector(<2 x i1> %t0) {
; CHECK-LABEL: @zext_vector(
; CHECK-NEXT:    [[T1:%.*]] = zext <2 x i1> [[T0:%.*]] to <2 x i32>
; CHECK-NEXT:    [[T2:%.*]] = icmp eq <2 x i32> [[T1]], <i32 2, i32 2>
; CHECK-NEXT:    ret <2 x i1> [[T2]]
;
  %t1 = zext <2 x i1> %t0 to <2 x i32>
  %t2 = icmp eq <2 x i32> %t1, <i32 2, i32 2>
  ret <2 x i1> %t2
}

; negative test. SCCP operates poorly with vector ranges

define <2 x i1> @zext_vector2(<2 x i1> %t0) {
; CHECK-LABEL: @zext_vector2(
; CHECK-NEXT:    [[T1:%.*]] = zext <2 x i1> [[T0:%.*]] to <2 x i32>
; CHECK-NEXT:    [[T2:%.*]] = add <2 x i32> [[T1]], <i32 2, i32 2>
; CHECK-NEXT:    [[T3:%.*]] = icmp eq <2 x i32> [[T1]], [[T2]]
; CHECK-NEXT:    ret <2 x i1> [[T3]]
;
  %t1 = zext <2 x i1> %t0 to <2 x i32>
  %t2 = add <2 x i32> %t1, <i32 2, i32 2>
  %t3 = icmp eq <2 x i32> %t1, %t2
  ret <2 x i1> %t3
}

; negative test: %t2 can be replaced by %t1, but SCCP operates by ranges only

define i32 @sext_ashr(i1 %t0) {
; CHECK-LABEL: @sext_ashr(
; CHECK-NEXT:    [[T1:%.*]] = sext i1 [[T0:%.*]] to i32
; CHECK-NEXT:    [[T2:%.*]] = ashr i32 [[T1]], 1
; CHECK-NEXT:    ret i32 [[T2]]
;
  %t1 = sext i1 %t0 to i32
  %t2 = ashr i32 %t1, 1
  ret i32 %t2
}

define i1 @sext_icmp(i1 %t0) {
; CHECK-LABEL: @sext_icmp(
; CHECK-NEXT:    [[T1:%.*]] = sext i1 [[T0:%.*]] to i32
; CHECK-NEXT:    ret i1 false
;
  %t1 = sext i1 %t0 to i32
  %t2 = icmp eq i32 %t1, 2
  ret i1 %t2
}

; negative test. SCCP operates poorly with vector ranges

define <2 x i1> @sext_vector(<2 x i1> %t0) {
; CHECK-LABEL: @sext_vector(
; CHECK-NEXT:    [[T1:%.*]] = sext <2 x i1> [[T0:%.*]] to <2 x i32>
; CHECK-NEXT:    [[T2:%.*]] = icmp eq <2 x i32> [[T1]], <i32 2, i32 2>
; CHECK-NEXT:    ret <2 x i1> [[T2]]
;
  %t1 = sext <2 x i1> %t0 to <2 x i32>
  %t2 = icmp eq <2 x i32> %t1, <i32 2, i32 2>
  ret <2 x i1> %t2
}

; negative test. SCCP operates poorly with vector ranges

define <2 x i1> @sext_vector2(<2 x i1> %t0) {
; CHECK-LABEL: @sext_vector2(
; CHECK-NEXT:    [[T1:%.*]] = sext <2 x i1> [[T0:%.*]] to <2 x i32>
; CHECK-NEXT:    [[T2:%.*]] = add <2 x i32> [[T1]], <i32 2, i32 2>
; CHECK-NEXT:    [[T3:%.*]] = icmp eq <2 x i32> [[T1]], [[T2]]
; CHECK-NEXT:    ret <2 x i1> [[T3]]
;
  %t1 = sext <2 x i1> %t0 to <2 x i32>
  %t2 = add <2 x i32> %t1, <i32 2, i32 2>
  %t3 = icmp eq <2 x i32> %t1, %t2
  ret <2 x i1> %t3
}