@@ -796,4 +796,52 @@ TEST_F(AArch64SelectionDAGTest, computeKnownBits_extload_knownnegative) {
796
796
EXPECT_EQ (Known.One , APInt (32 , 0xfffffff0 ));
797
797
}
798
798
799
+ TEST_F (AArch64SelectionDAGTest,
800
+ computeKnownBits_AVGFLOORU_AVGFLOORS_AVGCEILU_AVGCEILS) {
801
+ SDLoc Loc;
802
+ auto Int8VT = EVT::getIntegerVT (Context, 8 );
803
+ auto Int16VT = EVT::getIntegerVT (Context, 16 );
804
+ auto Int8Vec8VT = EVT::getVectorVT (Context, Int8VT, 8 );
805
+ auto Int16Vec8VT = EVT::getVectorVT (Context, Int16VT, 8 );
806
+
807
+ SDValue UnknownOp0 = DAG->getRegister (0 , Int8Vec8VT);
808
+ SDValue UnknownOp1 = DAG->getRegister (1 , Int8Vec8VT);
809
+
810
+ SDValue ZextOp0 =
811
+ DAG->getNode (ISD::ZERO_EXTEND, Loc, Int16Vec8VT, UnknownOp0);
812
+ SDValue ZextOp1 =
813
+ DAG->getNode (ISD::ZERO_EXTEND, Loc, Int16Vec8VT, UnknownOp1);
814
+ // ZextOp0 = 00000000????????
815
+ // ZextOp1 = 00000000????????
816
+ // => (for all AVG* instructions)
817
+ // Known.Zero = 1111111100000000 (0xFF00)
818
+ // Known.One = 0000000000000000 (0x0000)
819
+ auto Zeroes = APInt (16 , 0xFF00 );
820
+ auto Ones = APInt (16 , 0x0000 );
821
+
822
+ SDValue AVGFLOORU =
823
+ DAG->getNode (ISD::AVGFLOORU, Loc, Int16Vec8VT, ZextOp0, ZextOp1);
824
+ KnownBits KnownAVGFLOORU = DAG->computeKnownBits (AVGFLOORU);
825
+ EXPECT_EQ (KnownAVGFLOORU.Zero , Zeroes);
826
+ EXPECT_EQ (KnownAVGFLOORU.One , Ones);
827
+
828
+ SDValue AVGFLOORS =
829
+ DAG->getNode (ISD::AVGFLOORU, Loc, Int16Vec8VT, ZextOp0, ZextOp1);
830
+ KnownBits KnownAVGFLOORS = DAG->computeKnownBits (AVGFLOORS);
831
+ EXPECT_EQ (KnownAVGFLOORS.Zero , Zeroes);
832
+ EXPECT_EQ (KnownAVGFLOORS.One , Ones);
833
+
834
+ SDValue AVGCEILU =
835
+ DAG->getNode (ISD::AVGCEILU, Loc, Int16Vec8VT, ZextOp0, ZextOp1);
836
+ KnownBits KnownAVGCEILU = DAG->computeKnownBits (AVGCEILU);
837
+ EXPECT_EQ (KnownAVGCEILU.Zero , Zeroes);
838
+ EXPECT_EQ (KnownAVGCEILU.One , Ones);
839
+
840
+ SDValue AVGCEILS =
841
+ DAG->getNode (ISD::AVGCEILS, Loc, Int16Vec8VT, ZextOp0, ZextOp1);
842
+ KnownBits KnownAVGCEILS = DAG->computeKnownBits (AVGCEILS);
843
+ EXPECT_EQ (KnownAVGCEILS.Zero , Zeroes);
844
+ EXPECT_EQ (KnownAVGCEILS.One , Ones);
845
+ }
846
+
799
847
} // end namespace llvm
0 commit comments