@@ -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+
69154define 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
0 commit comments