diff --git a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp index 49f8761a13923..c12dc281b0e3c 100644 --- a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp +++ b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp @@ -363,6 +363,9 @@ SetVector ConstantHoistingPass::findConstantInsertionPoint( void ConstantHoistingPass::collectConstantCandidates( ConstCandMapType &ConstCandMap, Instruction *Inst, unsigned Idx, ConstantInt *ConstInt) { + if (ConstInt->getType()->isVectorTy()) + return; + InstructionCost Cost; // Ask the target about the cost of materializing the constant for the given // instruction and operand index. diff --git a/llvm/test/Transforms/ConstantHoisting/AArch64/large-immediate.ll b/llvm/test/Transforms/ConstantHoisting/AArch64/large-immediate.ll index 196a104adc023..6d8890d71e2be 100644 --- a/llvm/test/Transforms/ConstantHoisting/AArch64/large-immediate.ll +++ b/llvm/test/Transforms/ConstantHoisting/AArch64/large-immediate.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3 -; RUN: opt -mtriple=arm64-darwin-unknown -S -passes=consthoist < %s | FileCheck %s +; RUN: opt -mtriple=arm64-darwin-unknown -S -passes=consthoist < %s | FileCheck %s --check-prefixes=CHECK,CV +; RUN: opt -mtriple=arm64-darwin-unknown -S -passes=consthoist -use-constant-int-for-fixed-length-splat -use-constant-int-for-scalable-splat < %s | FileCheck %s --check-prefixes=CHECK,CI define i128 @test1(i128 %a) { ; CHECK-LABEL: define i128 @test1( @@ -122,13 +123,37 @@ define i64 @sdiv_minsize(i64 %a) minsize { } define <2 x i64> @sdiv_v2i64(<2 x i64> %a) { -; CHECK-LABEL: define <2 x i64> @sdiv_v2i64( -; CHECK-SAME: <2 x i64> [[A:%.*]]) { -; CHECK-NEXT: [[TMP1:%.*]] = sdiv <2 x i64> [[A]], -; CHECK-NEXT: [[TMP2:%.*]] = add <2 x i64> [[TMP1]], -; CHECK-NEXT: ret <2 x i64> [[TMP2]] +; CV-LABEL: define <2 x i64> @sdiv_v2i64( +; CV-SAME: <2 x i64> [[A:%.*]]) { +; CV-NEXT: [[TMP1:%.*]] = sdiv <2 x i64> [[A]], +; CV-NEXT: [[TMP2:%.*]] = add <2 x i64> [[TMP1]], +; CV-NEXT: ret <2 x i64> [[TMP2]] +; +; CI-LABEL: define <2 x i64> @sdiv_v2i64( +; CI-SAME: <2 x i64> [[A:%.*]]) { +; CI-NEXT: [[TMP1:%.*]] = sdiv <2 x i64> [[A]], splat (i64 4294967087) +; CI-NEXT: [[TMP2:%.*]] = add <2 x i64> [[TMP1]], splat (i64 4294967087) +; CI-NEXT: ret <2 x i64> [[TMP2]] ; %1 = sdiv <2 x i64> %a, %2 = add <2 x i64> %1, ret <2 x i64> %2 } + +define @sdiv_nxv2i64( %a) { +; CV-LABEL: define @sdiv_nxv2i64( +; CV-SAME: [[A:%.*]]) { +; CV-NEXT: [[TMP1:%.*]] = sdiv [[A]], shufflevector ( insertelement ( poison, i64 4294967087, i64 0), poison, zeroinitializer) +; CV-NEXT: [[TMP2:%.*]] = add [[TMP1]], shufflevector ( insertelement ( poison, i64 4294967087, i64 0), poison, zeroinitializer) +; CV-NEXT: ret [[TMP2]] +; +; CI-LABEL: define @sdiv_nxv2i64( +; CI-SAME: [[A:%.*]]) { +; CI-NEXT: [[TMP1:%.*]] = sdiv [[A]], splat (i64 4294967087) +; CI-NEXT: [[TMP2:%.*]] = add [[TMP1]], splat (i64 4294967087) +; CI-NEXT: ret [[TMP2]] +; + %1 = sdiv %a, splat (i64 4294967087) + %2 = add %1, splat (i64 4294967087) + ret %2 +}