Skip to content

Commit 9fe7625

Browse files
committed
[ValueTracking] Add tests for computeKnownBits of llvm.vector.reduce.{or,and}; NFC
1 parent 446d38c commit 9fe7625

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

llvm/test/Transforms/InstCombine/known-bits.ll

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,5 +1195,57 @@ define i1 @extract_value_smul_fail(i8 %xx, i8 %yy) {
11951195
ret i1 %r
11961196
}
11971197

1198+
define i8 @known_reduce_or(<2 x i8> %xx) {
1199+
; CHECK-LABEL: @known_reduce_or(
1200+
; CHECK-NEXT: [[X:%.*]] = or <2 x i8> [[XX:%.*]], <i8 5, i8 3>
1201+
; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.or.v2i8(<2 x i8> [[X]])
1202+
; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1
1203+
; CHECK-NEXT: ret i8 [[R]]
1204+
;
1205+
%x = or <2 x i8> %xx, <i8 5, i8 3>
1206+
%v = call i8 @llvm.vector.reduce.or(<2 x i8> %x)
1207+
%r = and i8 %v, 1
1208+
ret i8 %r
1209+
}
1210+
1211+
define i8 @known_reduce_or_fail(<2 x i8> %xx) {
1212+
; CHECK-LABEL: @known_reduce_or_fail(
1213+
; CHECK-NEXT: [[X:%.*]] = or <2 x i8> [[XX:%.*]], <i8 5, i8 3>
1214+
; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.or.v2i8(<2 x i8> [[X]])
1215+
; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 4
1216+
; CHECK-NEXT: ret i8 [[R]]
1217+
;
1218+
%x = or <2 x i8> %xx, <i8 5, i8 3>
1219+
%v = call i8 @llvm.vector.reduce.or(<2 x i8> %x)
1220+
%r = and i8 %v, 4
1221+
ret i8 %r
1222+
}
1223+
1224+
define i8 @known_reduce_and(<2 x i8> %xx) {
1225+
; CHECK-LABEL: @known_reduce_and(
1226+
; CHECK-NEXT: [[X:%.*]] = or <2 x i8> [[XX:%.*]], <i8 5, i8 3>
1227+
; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.or.v2i8(<2 x i8> [[X]])
1228+
; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1
1229+
; CHECK-NEXT: ret i8 [[R]]
1230+
;
1231+
%x = or <2 x i8> %xx, <i8 5, i8 3>
1232+
%v = call i8 @llvm.vector.reduce.or(<2 x i8> %x)
1233+
%r = and i8 %v, 1
1234+
ret i8 %r
1235+
}
1236+
1237+
define i8 @known_reduce_and_fail(<2 x i8> %xx) {
1238+
; CHECK-LABEL: @known_reduce_and_fail(
1239+
; CHECK-NEXT: [[X:%.*]] = or <2 x i8> [[XX:%.*]], <i8 5, i8 3>
1240+
; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.or.v2i8(<2 x i8> [[X]])
1241+
; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 2
1242+
; CHECK-NEXT: ret i8 [[R]]
1243+
;
1244+
%x = or <2 x i8> %xx, <i8 5, i8 3>
1245+
%v = call i8 @llvm.vector.reduce.or(<2 x i8> %x)
1246+
%r = and i8 %v, 2
1247+
ret i8 %r
1248+
}
1249+
11981250
declare void @use(i1)
11991251
declare void @sink(i8)

0 commit comments

Comments
 (0)