[llvm] [PatternMatch] Add a matching helper `m_ElementWiseBitCast`. NFC. (PR #80764)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 21:03:42 PST 2024
================
@@ -530,6 +530,35 @@ TEST_F(PatternMatchTest, ZExtSExtSelf) {
EXPECT_TRUE(m_ZExtOrSExtOrSelf(m_One()).match(One64S));
}
+TEST_F(PatternMatchTest, BitCast) {
+ Value *OneDouble = ConstantFP::get(IRB.getDoubleTy(), APFloat(1.0));
+ // scalar -> scalar
+ Value *DoubleToI64 = IRB.CreateBitCast(OneDouble, IRB.getInt64Ty());
+ // scalar -> vector
+ Value *DoubleToV2I32 = IRB.CreateBitCast(
+ OneDouble, VectorType::get(IRB.getInt32Ty(), 2, /*Scalable=*/false));
+ // vector -> scalar
+ Value *V2I32ToDouble = IRB.CreateBitCast(DoubleToV2I32, IRB.getDoubleTy());
+ // vector -> vector (same count)
+ Value *V2I32ToV2Float = IRB.CreateBitCast(
+ DoubleToV2I32, VectorType::get(IRB.getFloatTy(), 2, /*Scalable=*/false));
+ // vector -> vector (different count)
+ Value *V2I32TOV4I16 = IRB.CreateBitCast(
+ DoubleToV2I32, VectorType::get(IRB.getInt16Ty(), 4, /*Scalable=*/false));
+
----------------
arsenm wrote:
Test some scalable vector cases
https://github.com/llvm/llvm-project/pull/80764
More information about the llvm-commits
mailing list