Skip to content

Commit 23cea68

Browse files
committed
added more range tests
1 parent 4fbabd6 commit 23cea68

File tree

3 files changed

+258
-0
lines changed

3 files changed

+258
-0
lines changed

llvm/test/Analysis/DemandedBits/ashr.ll

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,91 @@ define i8 @test_ashr(i32 %a, i32 %b) {
6666
ret i8 %ashr.t
6767
}
6868

69+
define i8 @test_ashr_range_1(i32 %a, i32 %b) {
70+
; CHECK-LABEL: 'test_ashr_range_1'
71+
; CHECK-DAG: DemandedBits: 0xff for %shl.t = trunc i32 %ashr to i8
72+
; CHECK-DAG: DemandedBits: 0xff for %ashr in %shl.t = trunc i32 %ashr to i8
73+
; CHECK-DAG: DemandedBits: 0xffffffff for %b2 = and i32 %b, 3
74+
; CHECK-DAG: DemandedBits: 0x3 for %b in %b2 = and i32 %b, 3
75+
; CHECK-DAG: DemandedBits: 0xffffffff for 3 in %b2 = and i32 %b, 3
76+
; CHECK-DAG: DemandedBits: 0xff for %ashr = ashr i32 %a, %b2
77+
; CHECK-DAG: DemandedBits: 0x7ff for %a in %ashr = ashr i32 %a, %b2
78+
; CHECK-DAG: DemandedBits: 0xffffffff for %b2 in %ashr = ashr i32 %a, %b2
79+
;
80+
%b2 = and i32 %b, 3
81+
%ashr = ashr i32 %a, %b2
82+
%shl.t = trunc i32 %ashr to i8
83+
ret i8 %shl.t
84+
}
85+
86+
define i32 @test_ashr_range_2(i32 %a, i32 %b) {
87+
; CHECK-LABEL: 'test_ashr_range_2'
88+
; CHECK-DAG: DemandedBits: 0xffffffff for %b2 = and i32 %b, 3
89+
; CHECK-DAG: DemandedBits: 0x3 for %b in %b2 = and i32 %b, 3
90+
; CHECK-DAG: DemandedBits: 0xffffffff for 3 in %b2 = and i32 %b, 3
91+
; CHECK-DAG: DemandedBits: 0xffffffff for %ashr = ashr i32 %a, %b2
92+
; CHECK-DAG: DemandedBits: 0xffffffff for %a in %ashr = ashr i32 %a, %b2
93+
; CHECK-DAG: DemandedBits: 0xffffffff for %b2 in %ashr = ashr i32 %a, %b2
94+
;
95+
%b2 = and i32 %b, 3
96+
%ashr = ashr i32 %a, %b2
97+
ret i32 %ashr
98+
}
99+
100+
define i32 @test_ashr_range_3(i32 %a, i32 %b) {
101+
; CHECK-LABEL: 'test_ashr_range_3'
102+
; CHECK-DAG: DemandedBits: 0xffff for %ashr = ashr i32 %a, %b
103+
; CHECK-DAG: DemandedBits: 0xffffffff for %a in %ashr = ashr i32 %a, %b
104+
; CHECK-DAG: DemandedBits: 0xffffffff for %b in %ashr = ashr i32 %a, %b
105+
; CHECK-DAG: DemandedBits: 0xffffffff for %shl = shl i32 %ashr, 16
106+
; CHECK-DAG: DemandedBits: 0xffff for %ashr in %shl = shl i32 %ashr, 16
107+
; CHECK-DAG: DemandedBits: 0xffffffff for 16 in %shl = shl i32 %ashr, 16
108+
;
109+
%ashr = ashr i32 %a, %b
110+
%shl = shl i32 %ashr, 16
111+
ret i32 %shl
112+
}
113+
define i32 @test_ashr_range_4(i32 %a, i32 %b) {
114+
; CHECK-LABEL: 'test_ashr_range_4'
115+
; CHECK-DAG: DemandedBits: 0xffffffff for %shr = lshr i32 %ashr, 8
116+
; CHECK-DAG: DemandedBits: 0xffffff00 for %ashr in %shr = lshr i32 %ashr, 8
117+
; CHECK-DAG: DemandedBits: 0xffffffff for 8 in %shr = lshr i32 %ashr, 8
118+
; CHECK-DAG: DemandedBits: 0xffffff00 for %ashr = ashr i32 %a, %b
119+
; CHECK-DAG: DemandedBits: 0xffffff00 for %a in %ashr = ashr i32 %a, %b
120+
; CHECK-DAG: DemandedBits: 0xffffffff for %b in %ashr = ashr i32 %a, %b
121+
%ashr = ashr i32 %a, %b
122+
%shr = lshr i32 %ashr, 8
123+
ret i32 %shr
124+
}
125+
126+
define i32 @test_ashr_range_5(i32 %a, i32 %b) {
127+
; CHECK-LABEL: 'test_ashr_range_5'
128+
; CHECK-DAG: DemandedBits: 0xffffffff for %2 = and i32 %1, 255
129+
; CHECK-DAG: DemandedBits: 0xff for %1 in %2 = and i32 %1, 255
130+
; CHECK-DAG: DemandedBits: 0xffffffff for 255 in %2 = and i32 %1, 255
131+
; CHECK-DAG: DemandedBits: 0xff for %1 = ashr i32 %a, %b
132+
; CHECK-DAG: DemandedBits: 0xffffffff for %a in %1 = ashr i32 %a, %b
133+
; CHECK-DAG: DemandedBits: 0xffffffff for %b in %1 = ashr i32 %a, %b
134+
;
135+
%1 = ashr i32 %a, %b
136+
%2 = and i32 %1, 255
137+
ret i32 %2
138+
}
139+
140+
define i32 @test_ashr_range_6(i32 %a, i32 %b) {
141+
; CHECK-LABEL: 'test_ashr_range_6'
142+
; CHECK-DAG: DemandedBits: 0xffff0000 for %lshr.1 = ashr i32 %a, %b
143+
; CHECK-DAG: DemandedBits: 0xffff0000 for %a in %lshr.1 = ashr i32 %a, %b
144+
; CHECK-DAG: DemandedBits: 0xffffffff for %b in %lshr.1 = ashr i32 %a, %b
145+
; CHECK-DAG: DemandedBits: 0xffffffff for %lshr.2 = ashr i32 %lshr.1, 16
146+
; CHECK-DAG: DemandedBits: 0xffff0000 for %lshr.1 in %lshr.2 = ashr i32 %lshr.1, 16
147+
; CHECK-DAG: DemandedBits: 0xffffffff for 16 in %lshr.2 = ashr i32 %lshr.1, 16
148+
;
149+
%lshr.1 = ashr i32 %a, %b
150+
%lshr.2 = ashr i32 %lshr.1, 16
151+
ret i32 %lshr.2
152+
}
153+
69154
define i8 @test_ashr_var_amount(i32 %a, i32 %b){
70155
; CHECK-LABEL: 'test_ashr_var_amount'
71156
; CHECK-DAG: DemandedBits: 0xff for %4 = ashr i32 %1, %3

llvm/test/Analysis/DemandedBits/lshr.ll

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,93 @@ define i8 @test_lshr(i32 %a, i32 %b) {
6464
ret i8 %lshr.t
6565
}
6666

67+
define i8 @test_lshr_range_1(i32 %a, i32 %b) {
68+
; CHECK-LABEL: 'test_lshr_range_1'
69+
; CHECK-DAG: DemandedBits: 0xff for %shl.t = trunc i32 %lshr to i8
70+
; CHECK-DAG: DemandedBits: 0xff for %lshr in %shl.t = trunc i32 %lshr to i8
71+
; CHECK-DAG: DemandedBits: 0xff for %lshr = lshr i32 %a, %b2
72+
; CHECK-DAG: DemandedBits: 0x7ff for %a in %lshr = lshr i32 %a, %b2
73+
; CHECK-DAG: DemandedBits: 0xffffffff for %b2 in %lshr = lshr i32 %a, %b2
74+
; CHECK-DAG: DemandedBits: 0xffffffff for %b2 = and i32 %b, 3
75+
; CHECK-DAG: DemandedBits: 0x3 for %b in %b2 = and i32 %b, 3
76+
; CHECK-DAG: DemandedBits: 0xffffffff for 3 in %b2 = and i32 %b, 3
77+
;
78+
%b2 = and i32 %b, 3
79+
%lshr = lshr i32 %a, %b2
80+
%shl.t = trunc i32 %lshr to i8
81+
ret i8 %shl.t
82+
}
83+
84+
define i32 @test_lshr_range_2(i32 %a, i32 %b) {
85+
; CHECK-LABEL: 'test_lshr_range_2'
86+
; CHECK-DAG: DemandedBits: 0xffffffff for %lshr = lshr i32 %a, %b2
87+
; CHECK-DAG: DemandedBits: 0xffffffff for %a in %lshr = lshr i32 %a, %b2
88+
; CHECK-DAG: DemandedBits: 0xffffffff for %b2 in %lshr = lshr i32 %a, %b2
89+
; CHECK-DAG: DemandedBits: 0xffffffff for %b2 = and i32 %b, 3
90+
; CHECK-DAG: DemandedBits: 0x3 for %b in %b2 = and i32 %b, 3
91+
; CHECK-DAG: DemandedBits: 0xffffffff for 3 in %b2 = and i32 %b, 3
92+
;
93+
%b2 = and i32 %b, 3
94+
%lshr = lshr i32 %a, %b2
95+
ret i32 %lshr
96+
}
97+
98+
define i32 @test_lshr_range_3(i32 %a, i32 %b) {
99+
; CHECK-LABEL: 'test_lshr_range_3'
100+
; CHECK-DAG: DemandedBits: 0xffff for %lshr = lshr i32 %a, %b
101+
; CHECK-DAG: DemandedBits: 0xffffffff for %a in %lshr = lshr i32 %a, %b
102+
; CHECK-DAG: DemandedBits: 0xffffffff for %b in %lshr = lshr i32 %a, %b
103+
; CHECK-DAG: DemandedBits: 0xffffffff for %shl = shl i32 %lshr, 16
104+
; CHECK-DAG: DemandedBits: 0xffff for %lshr in %shl = shl i32 %lshr, 16
105+
; CHECK-DAG: DemandedBits: 0xffffffff for 16 in %shl = shl i32 %lshr, 16
106+
;
107+
%lshr = lshr i32 %a, %b
108+
%shl = shl i32 %lshr, 16
109+
ret i32 %shl
110+
}
111+
112+
define i32 @test_lshr_range_4(i32 %a, i32 %b) {
113+
; CHECK-LABEL: 'test_lshr_range_4'
114+
; CHECK-DAG: DemandedBits: 0xffffff00 for %lshr = lshr i32 %a, %b
115+
; CHECK-DAG: DemandedBits: 0xffffff00 for %a in %lshr = lshr i32 %a, %b
116+
; CHECK-DAG: DemandedBits: 0xffffffff for %b in %lshr = lshr i32 %a, %b
117+
; CHECK-DAG: DemandedBits: 0xffffffff for %shr = ashr i32 %lshr, 8
118+
; CHECK-DAG: DemandedBits: 0xffffff00 for %lshr in %shr = ashr i32 %lshr, 8
119+
; CHECK-DAG: DemandedBits: 0xffffffff for 8 in %shr = ashr i32 %lshr, 8
120+
%lshr = lshr i32 %a, %b
121+
%shr = ashr i32 %lshr, 8
122+
ret i32 %shr
123+
}
124+
125+
define i32 @test_lshr_range_5(i32 %a, i32 %b) {
126+
; CHECK-LABEL: 'test_lshr_range_5'
127+
; CHECK-DAG: DemandedBits: 0xff for %1 = lshr i32 %a, %b
128+
; CHECK-DAG: DemandedBits: 0xffffffff for %a in %1 = lshr i32 %a, %b
129+
; CHECK-DAG: DemandedBits: 0xffffffff for %b in %1 = lshr i32 %a, %b
130+
; CHECK-DAG: DemandedBits: 0xffffffff for %2 = and i32 %1, 255
131+
; CHECK-DAG: DemandedBits: 0xff for %1 in %2 = and i32 %1, 255
132+
; CHECK-DAG: DemandedBits: 0xffffffff for 255 in %2 = and i32 %1, 255
133+
;
134+
%1 = lshr i32 %a, %b
135+
%2 = and i32 %1, 255
136+
ret i32 %2
137+
}
138+
139+
define i32 @test_lshr_range_6(i32 %a, i32 %b) {
140+
; CHECK-LABEL: 'test_lshr_range_6'
141+
; CHECK-DAG: DemandedBits: 0xffff0000 for %lshr.1 = lshr i32 %a, %b
142+
; CHECK-DAG: DemandedBits: 0xffff0000 for %a in %lshr.1 = lshr i32 %a, %b
143+
; CHECK-DAG: DemandedBits: 0xffffffff for %b in %lshr.1 = lshr i32 %a, %b
144+
; CHECK-DAG: DemandedBits: 0xffffffff for %lshr.2 = lshr i32 %lshr.1, 16
145+
; CHECK-DAG: DemandedBits: 0xffff0000 for %lshr.1 in %lshr.2 = lshr i32 %lshr.1, 16
146+
; CHECK-DAG: DemandedBits: 0xffffffff for 16 in %lshr.2 = lshr i32 %lshr.1, 16
147+
;
148+
%lshr.1 = lshr i32 %a, %b
149+
%lshr.2 = lshr i32 %lshr.1, 16
150+
ret i32 %lshr.2
151+
}
152+
153+
67154
define i8 @test_lshr_var_amount(i32 %a, i32 %b){
68155
; CHECK-LABEL: 'test_lshr_var_amount'
69156
; CHECK-DAG: DemandedBits: 0xff for %4 = lshr i32 %1, %3

llvm/test/Analysis/DemandedBits/shl.ll

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,92 @@ define i8 @test_shl(i32 %a, i32 %b) {
6565
ret i8 %shl.t
6666
}
6767

68+
define i8 @test_shl_range_1(i32 %a, i32 %b) {
69+
; CHECK-LABEL: 'test_shl_range_1'
70+
; CHECK-DAG: DemandedBits: 0xff for %shl = shl i32 %a, %b2
71+
; CHECK-DAG: DemandedBits: 0xff for %a in %shl = shl i32 %a, %b2
72+
; CHECK-DAG: DemandedBits: 0xffffffff for %b2 in %shl = shl i32 %a, %b2
73+
; CHECK-DAG: DemandedBits: 0xff for %shl.t = trunc i32 %shl to i8
74+
; CHECK-DAG: DemandedBits: 0xff for %shl in %shl.t = trunc i32 %shl to i8
75+
; CHECK-DAG: DemandedBits: 0xffffffff for %b2 = and i32 %b, 3
76+
; CHECK-DAG: DemandedBits: 0x3 for %b in %b2 = and i32 %b, 3
77+
; CHECK-DAG: DemandedBits: 0xffffffff for 3 in %b2 = and i32 %b, 3
78+
;
79+
%b2 = and i32 %b, 3
80+
%shl = shl i32 %a, %b2
81+
%shl.t = trunc i32 %shl to i8
82+
ret i8 %shl.t
83+
}
84+
85+
define i32 @test_shl_range_2(i32 %a, i32 %b) {
86+
; CHECK-LABEL: 'test_shl_range_2'
87+
; CHECK-DAG: DemandedBits: 0xffffffff for %b2 = and i32 %b, 3
88+
; CHECK-DAG: DemandedBits: 0x3 for %b in %b2 = and i32 %b, 3
89+
; CHECK-DAG: DemandedBits: 0xffffffff for 3 in %b2 = and i32 %b, 3
90+
; CHECK-DAG: DemandedBits: 0xffffffff for %shl = shl i32 %a, %b2
91+
; CHECK-DAG: DemandedBits: 0xffffffff for %a in %shl = shl i32 %a, %b2
92+
; CHECK-DAG: DemandedBits: 0xffffffff for %b2 in %shl = shl i32 %a, %b2
93+
;
94+
%b2 = and i32 %b, 3
95+
%shl = shl i32 %a, %b2
96+
ret i32 %shl
97+
}
98+
99+
define i32 @test_shl_range_3(i32 %a, i32 %b) {
100+
; CHECK-LABEL: 'test_shl_range_3'
101+
; CHECK-DAG: DemandedBits: 0xffffffff for %shr = lshr i32 %shl, 16
102+
; CHECK-DAG: DemandedBits: 0xffff0000 for %shl in %shr = lshr i32 %shl, 16
103+
; CHECK-DAG: DemandedBits: 0xffffffff for 16 in %shr = lshr i32 %shl, 16
104+
; CHECK-DAG: DemandedBits: 0xffff0000 for %shl = shl i32 %a, %b
105+
; CHECK-DAG: DemandedBits: 0xffffffff for %a in %shl = shl i32 %a, %b
106+
; CHECK-DAG: DemandedBits: 0xffffffff for %b in %shl = shl i32 %a, %b
107+
;
108+
%shl = shl i32 %a, %b
109+
%shr = lshr i32 %shl, 16
110+
ret i32 %shr
111+
}
112+
113+
define i32 @test_shl_range_4(i32 %a, i32 %b) {
114+
; CHECK-LABEL: 'test_shl_range_4'
115+
; CHECK-DAG: DemandedBits: 0xffffffff for %shr = ashr i32 %shl, 8
116+
; CHECK-DAG: DemandedBits: 0xffffff00 for %shl in %shr = ashr i32 %shl, 8
117+
; CHECK-DAG: DemandedBits: 0xffffffff for 8 in %shr = ashr i32 %shl, 8
118+
; CHECK-DAG: DemandedBits: 0xffffff00 for %shl = shl i32 %a, %b
119+
; CHECK-DAG: DemandedBits: 0xffffffff for %a in %shl = shl i32 %a, %b
120+
; CHECK-DAG: DemandedBits: 0xffffffff for %b in %shl = shl i32 %a, %b
121+
%shl = shl i32 %a, %b
122+
%shr = ashr i32 %shl, 8
123+
ret i32 %shr
124+
}
125+
126+
define i32 @test_shl_range_5(i32 %a, i32 %b) {
127+
; CHECK-LABEL: 'test_shl_range_5'
128+
; CHECK-DAG: DemandedBits: 0xff for %1 = shl i32 %a, %b
129+
; CHECK-DAG: DemandedBits: 0xff for %a in %1 = shl i32 %a, %b
130+
; CHECK-DAG: DemandedBits: 0xffffffff for %b in %1 = shl i32 %a, %b
131+
; CHECK-DAG: DemandedBits: 0xffffffff for %2 = and i32 %1, 255
132+
; CHECK-DAG: DemandedBits: 0xff for %1 in %2 = and i32 %1, 255
133+
; CHECK-DAG: DemandedBits: 0xffffffff for 255 in %2 = and i32 %1, 255
134+
;
135+
%1 = shl i32 %a, %b
136+
%2 = and i32 %1, 255
137+
ret i32 %2
138+
}
139+
140+
define i32 @test_shl_range_6(i32 %a, i32 %b) {
141+
; CHECK-LABEL: 'test_shl_range_6'
142+
; CHECK-DAG: DemandedBits: 0xffffffff for %shl.2 = shl i32 %shl.1, 16
143+
; CHECK-DAG: DemandedBits: 0xffff for %shl.1 in %shl.2 = shl i32 %shl.1, 16
144+
; CHECK-DAG: DemandedBits: 0xffffffff for 16 in %shl.2 = shl i32 %shl.1, 16
145+
; CHECK-DAG: DemandedBits: 0xffff for %shl.1 = shl i32 %a, %b
146+
; CHECK-DAG: DemandedBits: 0xffff for %a in %shl.1 = shl i32 %a, %b
147+
; CHECK-DAG: DemandedBits: 0xffffffff for %b in %shl.1 = shl i32 %a, %b
148+
;
149+
%shl.1 = shl i32 %a, %b
150+
%shl.2 = shl i32 %shl.1, 16
151+
ret i32 %shl.2
152+
}
153+
68154
define i8 @test_shl_var_amount(i32 %a, i32 %b){
69155
; CHECK-LABEL: 'test_shl_var_amount'
70156
; CHECK-DAG: DemandedBits: 0xff for %5 = trunc i32 %4 to i8

0 commit comments

Comments
 (0)