xref: /llvm-project/llvm/test/Analysis/DemandedBits/vectors-inseltpoison.ll (revision 38fffa630ee80163dc65e759392ad29798905679)
130365472SJuneyoung Lee; RUN: opt -S -disable-output -passes="print<demanded-bits>" < %s 2>&1 | FileCheck %s
230365472SJuneyoung Lee
330365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xff00 for   %x = or <2 x i32> %a, zeroinitializer
430365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xff00 for   %y = or <2 x i32> %b, zeroinitializer
530365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xff00 for   %z = or <2 x i32> %x, %y
6*38fffa63SPaul Walker; CHECK-DAG: DemandedBits: 0xff for   %u = lshr <2 x i32> %z, splat (i32 8)
730365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xff for   %r = trunc <2 x i32> %u to <2 x i8>
830365472SJuneyoung Leedefine <2 x i8> @test_basic(<2 x i32> %a, <2 x i32> %b) {
930365472SJuneyoung Lee  %x = or <2 x i32> %a, zeroinitializer
1030365472SJuneyoung Lee  %y = or <2 x i32> %b, zeroinitializer
1130365472SJuneyoung Lee  %z = or <2 x i32> %x, %y
1230365472SJuneyoung Lee  %u = lshr <2 x i32> %z, <i32 8, i32 8>
1330365472SJuneyoung Lee  %r = trunc <2 x i32> %u to <2 x i8>
1430365472SJuneyoung Lee  ret <2 x i8> %r
1530365472SJuneyoung Lee}
1630365472SJuneyoung Lee
1730365472SJuneyoung Lee; Vector-specific instructions
1830365472SJuneyoung Lee
1930365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xff for   %x = or <2 x i32> %a, zeroinitializer
2030365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xf0 for   %z = extractelement <2 x i32> %x, i32 1
2130365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xf for   %y = extractelement <2 x i32> %x, i32 0
2230365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xffffffff for   %u = and i32 %y, 15
2330365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xffffffff for   %v = and i32 %z, 240
2430365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xffffffff for   %r = or i32 %u, %v
2530365472SJuneyoung Leedefine i32 @test_extractelement(<2 x i32> %a) {
2630365472SJuneyoung Lee  %x = or <2 x i32> %a, zeroinitializer
2730365472SJuneyoung Lee  %y = extractelement <2 x i32> %x, i32 0
2830365472SJuneyoung Lee  %z = extractelement <2 x i32> %x, i32 1
2930365472SJuneyoung Lee  %u = and i32 %y, 15
3030365472SJuneyoung Lee  %v = and i32 %z, 240
3130365472SJuneyoung Lee  %r = or i32 %u, %v
3230365472SJuneyoung Lee  ret i32 %r
3330365472SJuneyoung Lee}
3430365472SJuneyoung Lee
3530365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xff for   %x = or i32 %a, 0
3630365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xff for   %y = or i32 %b, 0
3730365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xff for   %z = insertelement <2 x i32> poison, i32 %x, i32 0
3830365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xff for   %u = insertelement <2 x i32> %z, i32 %y, i32 1
3930365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xffffffff for   %r = and <2 x i32> %u, <i32 255, i32 127>
4030365472SJuneyoung Leedefine <2 x i32> @test_insertelement(i32 %a, i32 %b) {
4130365472SJuneyoung Lee  %x = or i32 %a, 0
4230365472SJuneyoung Lee  %y = or i32 %b, 0
4330365472SJuneyoung Lee  %z = insertelement <2 x i32> poison, i32 %x, i32 0
4430365472SJuneyoung Lee  %u = insertelement <2 x i32> %z, i32 %y, i32 1
4530365472SJuneyoung Lee  %r = and <2 x i32> %u, <i32 255, i32 127>
4630365472SJuneyoung Lee  ret <2 x i32> %r
4730365472SJuneyoung Lee}
4830365472SJuneyoung Lee
4930365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xff for   %x = or <2 x i32> %a, zeroinitializer
5030365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xff for   %y = or <2 x i32> %b, zeroinitializer
5130365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xff for   %z = shufflevector <2 x i32> %x, <2 x i32> %y, <3 x i32> <i32 0, i32 3, i32 1>
5230365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xffffffff for   %r = and <3 x i32> %z, <i32 255, i32 127, i32 0>
5330365472SJuneyoung Leedefine <3 x i32> @test_shufflevector(<2 x i32> %a, <2 x i32> %b) {
5430365472SJuneyoung Lee  %x = or <2 x i32> %a, zeroinitializer
5530365472SJuneyoung Lee  %y = or <2 x i32> %b, zeroinitializer
5630365472SJuneyoung Lee  %z = shufflevector <2 x i32> %x, <2 x i32> %y, <3 x i32> <i32 0, i32 3, i32 1>
5730365472SJuneyoung Lee  %r = and <3 x i32> %z, <i32 255, i32 127, i32 0>
5830365472SJuneyoung Lee  ret <3 x i32> %r
5930365472SJuneyoung Lee}
6030365472SJuneyoung Lee
6130365472SJuneyoung Lee; Shifts with splat shift amounts
6230365472SJuneyoung Lee
6330365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xf for   %x = or <2 x i32> %a, zeroinitializer
64*38fffa63SPaul Walker; CHECK-DAG: DemandedBits: 0xf0 for   %y = shl <2 x i32> %x, splat (i32 4)
65*38fffa63SPaul Walker; CHECK-DAG: DemandedBits: 0xffffffff for   %r = and <2 x i32> %y, splat (i32 240)
6630365472SJuneyoung Leedefine <2 x i32> @test_shl(<2 x i32> %a) {
6730365472SJuneyoung Lee  %x = or <2 x i32> %a, zeroinitializer
6830365472SJuneyoung Lee  %y = shl <2 x i32> %x, <i32 4, i32 4>
6930365472SJuneyoung Lee  %r = and <2 x i32> %y, <i32 240, i32 240>
7030365472SJuneyoung Lee  ret <2 x i32> %r
7130365472SJuneyoung Lee}
7230365472SJuneyoung Lee
7330365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xf00 for   %x = or <2 x i32> %a, zeroinitializer
74*38fffa63SPaul Walker; CHECK-DAG: DemandedBits: 0xf0 for   %y = ashr <2 x i32> %x, splat (i32 4)
75*38fffa63SPaul Walker; CHECK-DAG: DemandedBits: 0xffffffff for   %r = and <2 x i32> %y, splat (i32 240)
7630365472SJuneyoung Leedefine <2 x i32> @test_ashr(<2 x i32> %a) {
7730365472SJuneyoung Lee  %x = or <2 x i32> %a, zeroinitializer
7830365472SJuneyoung Lee  %y = ashr <2 x i32> %x, <i32 4, i32 4>
7930365472SJuneyoung Lee  %r = and <2 x i32> %y, <i32 240, i32 240>
8030365472SJuneyoung Lee  ret <2 x i32> %r
8130365472SJuneyoung Lee}
8230365472SJuneyoung Lee
8330365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xf00 for   %x = or <2 x i32> %a, zeroinitializer
84*38fffa63SPaul Walker; CHECK-DAG: DemandedBits: 0xf0 for   %y = lshr <2 x i32> %x, splat (i32 4)
85*38fffa63SPaul Walker; CHECK-DAG: DemandedBits: 0xffffffff for   %r = and <2 x i32> %y, splat (i32 240)
8630365472SJuneyoung Leedefine <2 x i32> @test_lshr(<2 x i32> %a) {
8730365472SJuneyoung Lee  %x = or <2 x i32> %a, zeroinitializer
8830365472SJuneyoung Lee  %y = lshr <2 x i32> %x, <i32 4, i32 4>
8930365472SJuneyoung Lee  %r = and <2 x i32> %y, <i32 240, i32 240>
9030365472SJuneyoung Lee  ret <2 x i32> %r
9130365472SJuneyoung Lee}
9230365472SJuneyoung Lee
9330365472SJuneyoung Leedeclare <2 x i32> @llvm.fshl.i32(<2 x i32>, <2 x i32>, <2 x i32>)
9430365472SJuneyoung Leedeclare <2 x i32> @llvm.fshr.i32(<2 x i32>, <2 x i32>, <2 x i32>)
9530365472SJuneyoung Lee
9630365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xf for   %x = or <2 x i32> %a, zeroinitializer
9730365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xf0000000 for   %y = or <2 x i32> %b, zeroinitializer
98*38fffa63SPaul Walker; CHECK-DAG: DemandedBits: 0xff for   %z = call <2 x i32> @llvm.fshl.v2i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> splat (i32 4))
99*38fffa63SPaul Walker; CHECK-DAG: DemandedBits: 0xffffffff for   %r = and <2 x i32> %z, splat (i32 255)
10030365472SJuneyoung Leedefine <2 x i32> @test_fshl(<2 x i32> %a, <2 x i32> %b) {
10130365472SJuneyoung Lee  %x = or <2 x i32> %a, zeroinitializer
10230365472SJuneyoung Lee  %y = or <2 x i32> %b, zeroinitializer
10330365472SJuneyoung Lee  %z = call <2 x i32> @llvm.fshl.i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> <i32 4, i32 4>)
10430365472SJuneyoung Lee  %r = and <2 x i32> %z, <i32 255, i32 255>
10530365472SJuneyoung Lee  ret <2 x i32> %r
10630365472SJuneyoung Lee}
10730365472SJuneyoung Lee
10830365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xf for   %x = or <2 x i32> %a, zeroinitializer
10930365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xf0000000 for   %y = or <2 x i32> %b, zeroinitializer
110*38fffa63SPaul Walker; CHECK-DAG: DemandedBits: 0xff for   %z = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> splat (i32 28))
111*38fffa63SPaul Walker; CHECK-DAG: DemandedBits: 0xffffffff for   %r = and <2 x i32> %z, splat (i32 255)
11230365472SJuneyoung Leedefine <2 x i32> @test_fshr(<2 x i32> %a, <2 x i32> %b) {
11330365472SJuneyoung Lee  %x = or <2 x i32> %a, zeroinitializer
11430365472SJuneyoung Lee  %y = or <2 x i32> %b, zeroinitializer
11530365472SJuneyoung Lee  %z = call <2 x i32> @llvm.fshr.i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> <i32 28, i32 28>)
11630365472SJuneyoung Lee  %r = and <2 x i32> %z, <i32 255, i32 255>
11730365472SJuneyoung Lee  ret <2 x i32> %r
11830365472SJuneyoung Lee}
11930365472SJuneyoung Lee
12030365472SJuneyoung Lee; FP / Int conversion. These have different input / output types.
12130365472SJuneyoung Lee
12230365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xffffffff for   %x = or <2 x i32> %a, zeroinitializer
12330365472SJuneyoung Leedefine <2 x float> @test_uitofp(<2 x i32> %a) {
12430365472SJuneyoung Lee  %x = or <2 x i32> %a, zeroinitializer
12530365472SJuneyoung Lee  %r = uitofp <2 x i32> %x to <2 x float>
12630365472SJuneyoung Lee  ret <2 x float> %r
12730365472SJuneyoung Lee}
12830365472SJuneyoung Lee
12930365472SJuneyoung Lee; CHECK-DAG: DemandedBits: 0xffffffff for   %y = fptoui <2 x float> %x to <2 x i32>
13030365472SJuneyoung Leedefine <2 x i32> @test_fptoui(<2 x float> %a) {
13130365472SJuneyoung Lee  %x = fadd <2 x float> %a, <float 1.0, float 1.0>
13230365472SJuneyoung Lee  %y = fptoui <2 x float> %x to <2 x i32>
13330365472SJuneyoung Lee  %r = and <2 x i32> %y, <i32 255, i32 255>
13430365472SJuneyoung Lee  ret <2 x i32> %y
13530365472SJuneyoung Lee}
136