1ef78edafSAlexey Bataev; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 2ef78edafSAlexey Bataev; RUN: opt -S --passes=slp-vectorizer -mtriple=riscv64-unknown-linux-gnu -mattr=+v < %s | FileCheck %s 3ef78edafSAlexey Bataev@c = global [12 x i64] zeroinitializer 4ef78edafSAlexey Bataev 5ef78edafSAlexey Bataev; FIXME: after minbitwidth analysis and i32 conv.., 65535 is transformed to 6ef78edafSAlexey Bataev; and <4 x i16> , -1, which must be dropped. 7ef78edafSAlexey Bataev; FIXME: need to adjust the cost of the final transformation, since the user is 8ef78edafSAlexey Bataev; just a trunc to i16 (it must be free). 9ef78edafSAlexey Bataevdefine i16 @test() { 10ef78edafSAlexey Bataev; CHECK-LABEL: define i16 @test( 11ef78edafSAlexey Bataev; CHECK-SAME: ) #[[ATTR0:[0-9]+]] { 12ef78edafSAlexey Bataev; CHECK-NEXT: entry: 13*38fffa63SPaul Walker; CHECK-NEXT: [[TMP0:%.*]] = call <4 x i64> @llvm.experimental.vp.strided.load.v4i64.p0.i64(ptr align 8 @c, i64 24, <4 x i1> splat (i1 true), i32 4) 14ef78edafSAlexey Bataev; CHECK-NEXT: [[TMP1:%.*]] = trunc <4 x i64> [[TMP0]] to <4 x i16> 15*38fffa63SPaul Walker; CHECK-NEXT: [[TMP3:%.*]] = xor <4 x i16> [[TMP1]], splat (i16 -1) 16ef78edafSAlexey Bataev; CHECK-NEXT: [[TMP4:%.*]] = call i16 @llvm.vector.reduce.umax.v4i16(<4 x i16> [[TMP3]]) 17ef78edafSAlexey Bataev; CHECK-NEXT: [[TMP5:%.*]] = zext i16 [[TMP4]] to i32 18ef78edafSAlexey Bataev; CHECK-NEXT: [[T:%.*]] = trunc i32 [[TMP5]] to i16 19ef78edafSAlexey Bataev; CHECK-NEXT: ret i16 [[T]] 20ef78edafSAlexey Bataev; 21ef78edafSAlexey Bataeventry: 22ef78edafSAlexey Bataev %0 = load i64, ptr @c, align 8 23ef78edafSAlexey Bataev %conv = trunc i64 %0 to i32 24ef78edafSAlexey Bataev %conv3 = and i32 %conv, 65535 25ef78edafSAlexey Bataev %conv4 = xor i32 %conv3, 65535 26ef78edafSAlexey Bataev %1 = load i64, ptr getelementptr inbounds ([12 x i64], ptr @c, i64 0, i64 3), align 8 27ef78edafSAlexey Bataev %conv.1 = trunc i64 %1 to i32 28ef78edafSAlexey Bataev %conv3.1 = and i32 %conv.1, 65535 29ef78edafSAlexey Bataev %conv4.1 = xor i32 %conv3.1, 65535 30ef78edafSAlexey Bataev %.conv4.1 = tail call i32 @llvm.umax.i32(i32 %conv4, i32 %conv4.1) 31ef78edafSAlexey Bataev %2 = load i64, ptr getelementptr inbounds ([12 x i64], ptr @c, i64 0, i64 6), align 8 32ef78edafSAlexey Bataev %conv.2 = trunc i64 %2 to i32 33ef78edafSAlexey Bataev %conv3.2 = and i32 %conv.2, 65535 34ef78edafSAlexey Bataev %conv4.2 = xor i32 %conv3.2, 65535 35ef78edafSAlexey Bataev %.conv4.2 = tail call i32 @llvm.umax.i32(i32 %.conv4.1, i32 %conv4.2) 36ef78edafSAlexey Bataev %3 = load i64, ptr getelementptr inbounds ([12 x i64], ptr @c, i64 0, i64 9), align 8 37ef78edafSAlexey Bataev %conv.3 = trunc i64 %3 to i32 38ef78edafSAlexey Bataev %conv3.3 = and i32 %conv.3, 65535 39ef78edafSAlexey Bataev %conv4.3 = xor i32 %conv3.3, 65535 40ef78edafSAlexey Bataev %.conv4.3 = tail call i32 @llvm.umax.i32(i32 %.conv4.2, i32 %conv4.3) 41ef78edafSAlexey Bataev %t = trunc i32 %.conv4.3 to i16 42ef78edafSAlexey Bataev ret i16 %t 43ef78edafSAlexey Bataev} 44