Skip to content

Commit 9014d98

Browse files
committed
ValueTracking/test: cover known-high-bits of rem
There is an underlying bug in KnownBits, and we should theoretically be able to determine the high-bits of an srem as shown in the test, just like urem. In preparation to fix this bug, add pre-commit tests testing high-bits of srem and urem.
1 parent 4de7026 commit 9014d98

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

llvm/test/Analysis/ValueTracking/knownbits-rem-lowbits.ll renamed to llvm/test/Analysis/ValueTracking/knownbits-rem.ll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ define i8 @urem_low_bits_know(i8 %xx, i8 %yy) {
1212
ret i8 %r
1313
}
1414

15+
define i8 @urem_high_bits_know(i8 %xx, i8 %yy) {
16+
; CHECK-LABEL: @urem_high_bits_know(
17+
; CHECK-NEXT: ret i8 0
18+
;
19+
%x = and i8 %xx, 2
20+
%y = and i8 %yy, -4
21+
%rem = urem i8 %x, %y
22+
%r = and i8 %rem, 8
23+
ret i8 %r
24+
}
25+
1526
define i8 @urem_low_bits_know2(i8 %xx, i8 %yy) {
1627
; CHECK-LABEL: @urem_low_bits_know2(
1728
; CHECK-NEXT: ret i8 2
@@ -80,6 +91,21 @@ define i8 @srem_low_bits_know(i8 %xx, i8 %yy) {
8091
ret i8 %r
8192
}
8293

94+
define i8 @srem_high_bits_know(i8 %xx, i8 %yy) {
95+
; CHECK-LABEL: @srem_high_bits_know(
96+
; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], -2
97+
; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], -4
98+
; CHECK-NEXT: [[REM:%.*]] = srem i8 [[X]], [[Y]]
99+
; CHECK-NEXT: [[R:%.*]] = and i8 [[REM]], 8
100+
; CHECK-NEXT: ret i8 [[R]]
101+
;
102+
%x = or i8 %xx, -2
103+
%y = and i8 %yy, -4
104+
%rem = srem i8 %x, %y
105+
%r = and i8 %rem, 8
106+
ret i8 %r
107+
}
108+
83109
define i8 @srem_low_bits_know2(i8 %xx, i8 %yy) {
84110
; CHECK-LABEL: @srem_low_bits_know2(
85111
; CHECK-NEXT: ret i8 1

0 commit comments

Comments
 (0)