File tree Expand file tree Collapse file tree 5 files changed +17
-9
lines changed Expand file tree Collapse file tree 5 files changed +17
-9
lines changed Original file line number Diff line number Diff line change 971
971
(rule 1 (lower_ctz (fits_in_16 ty) x)
972
972
(if-let $true (has_zbb))
973
973
(let ((tmp Reg (bseti x (ty_bits ty))))
974
- (alu_rr_funct12 (AluOPRRI.Ctzw) x )))
974
+ (alu_rr_funct12 (AluOPRRI.Ctzw) tmp )))
975
975
976
976
(rule 2 (lower_ctz $I32 x)
977
977
(if-let $true (has_zbb))
Original file line number Diff line number Diff line change @@ -11,13 +11,13 @@ block0(v0: i8):
11
11
; VCode:
12
12
; block0:
13
13
; bseti t2,a0,8
14
- ; ctzw a0,a0
14
+ ; ctzw a0,t2
15
15
; ret
16
16
;
17
17
; Disassembled:
18
18
; block0: ; offset 0x0
19
19
; .byte 0x93, 0x13, 0x85, 0x28
20
- ; .byte 0x1b, 0x15, 0x15 , 0x60
20
+ ; .byte 0x1b, 0x95, 0x13 , 0x60
21
21
; ret
22
22
23
23
function %ctz_i16(i16) -> i16 {
@@ -29,13 +29,13 @@ block0(v0: i16):
29
29
; VCode:
30
30
; block0:
31
31
; bseti t2,a0,16
32
- ; ctzw a0,a0
32
+ ; ctzw a0,t2
33
33
; ret
34
34
;
35
35
; Disassembled:
36
36
; block0: ; offset 0x0
37
37
; .byte 0x93, 0x13, 0x05, 0x29
38
- ; .byte 0x1b, 0x15, 0x15 , 0x60
38
+ ; .byte 0x1b, 0x95, 0x13 , 0x60
39
39
; ret
40
40
41
41
function %ctz_i32(i32) -> i32 {
Original file line number Diff line number Diff line change @@ -12,13 +12,13 @@ block0(v0: i8):
12
12
; VCode:
13
13
; block0:
14
14
; ori t2,a0,256
15
- ; ctzw a0,a0
15
+ ; ctzw a0,t2
16
16
; ret
17
17
;
18
18
; Disassembled:
19
19
; block0: ; offset 0x0
20
20
; ori t2, a0, 0x100
21
- ; .byte 0x1b, 0x15, 0x15 , 0x60
21
+ ; .byte 0x1b, 0x95, 0x13 , 0x60
22
22
; ret
23
23
24
24
function %ctz_i16(i16) -> i16 {
@@ -31,14 +31,14 @@ block0(v0: i16):
31
31
; block0:
32
32
; lui t2,16
33
33
; or a1,a0,t2
34
- ; ctzw a0,a0
34
+ ; ctzw a0,a1
35
35
; ret
36
36
;
37
37
; Disassembled:
38
38
; block0: ; offset 0x0
39
39
; lui t2, 0x10
40
40
; or a1, a0, t2
41
- ; .byte 0x1b, 0x15 , 0x15, 0x60
41
+ ; .byte 0x1b, 0x95 , 0x15, 0x60
42
42
; ret
43
43
44
44
function %ctz_i32(i32) -> i32 {
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ block0(v0: i8):
12
12
v1 = clz v0
13
13
return v1
14
14
}
15
+ ; run: %clz_i8(0) == 8
15
16
; run: %clz_i8(1) == 7
16
17
; run: %clz_i8(0x40) == 1
17
18
; run: %clz_i8(-1) == 0
@@ -21,6 +22,7 @@ block0(v0: i16):
21
22
v1 = clz v0
22
23
return v1
23
24
}
25
+ ; run: %clz_i16(0) == 16
24
26
; run: %clz_i16(1) == 15
25
27
; run: %clz_i16(0x4000) == 1
26
28
; run: %clz_i16(-1) == 0
@@ -30,6 +32,7 @@ block0(v0: i32):
30
32
v1 = clz v0
31
33
return v1
32
34
}
35
+ ; run: %clz_i32(0) == 32
33
36
; run: %clz_i32(1) == 31
34
37
; run: %clz_i32(0x40000000) == 1
35
38
; run: %clz_i32(-1) == 0
@@ -39,6 +42,7 @@ block0(v0: i64):
39
42
v1 = clz v0
40
43
return v1
41
44
}
45
+ ; run: %clz_i64(0) == 64
42
46
; run: %clz_i64(1) == 63
43
47
; run: %clz_i64(0x4000000000000000) == 1
44
48
; run: %clz_i64(-1) == 0
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ block0(v0: i8):
13
13
v1 = ctz v0
14
14
return v1
15
15
}
16
+ ; run: %ctz_i8(0) == 8
16
17
; run: %ctz_i8(1) == 0
17
18
; run: %ctz_i8(0x40) == 6
18
19
; run: %ctz_i8(-1) == 0
@@ -22,6 +23,7 @@ block0(v0: i16):
22
23
v1 = ctz v0
23
24
return v1
24
25
}
26
+ ; run: %ctz_i16(0) == 16
25
27
; run: %ctz_i16(1) == 0
26
28
; run: %ctz_i16(0x4000) == 14
27
29
; run: %ctz_i16(-1) == 0
@@ -31,6 +33,7 @@ block0(v0: i32):
31
33
v1 = ctz v0
32
34
return v1
33
35
}
36
+ ; run: %ctz_i32(0) == 32
34
37
; run: %ctz_i32(1) == 0
35
38
; run: %ctz_i32(0x40000000) == 30
36
39
; run: %ctz_i32(-1) == 0
@@ -40,6 +43,7 @@ block0(v0: i64):
40
43
v1 = ctz v0
41
44
return v1
42
45
}
46
+ ; run: %ctz_i64(0) == 64
43
47
; run: %ctz_i64(1) == 0
44
48
; run: %ctz_i64(0x4000000000000000) == 62
45
49
; run: %ctz_i64(-1) == 0
You can’t perform that action at this time.
0 commit comments