From: David Sherwood Date: Wed, 27 May 2020 14:21:48 +0000 (+0100) Subject: [SVE] Fix warnings in SelectInst::areInvalidOperands X-Git-Tag: llvmorg-12-init~4760 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9c0ef044beb4850ad9626cb81a1ede4f3bbda4a7;p=platform%2Fupstream%2Fllvm.git [SVE] Fix warnings in SelectInst::areInvalidOperands We should be comparing the element counts rather than the numbers of elements. Differential Revision: https://reviews.llvm.org/D80634 --- diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index 957db32..3c7b795 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -81,7 +81,7 @@ const char *SelectInst::areInvalidOperands(Value *Op0, Value *Op1, Value *Op2) { VectorType *ET = dyn_cast(Op1->getType()); if (!ET) return "selected values for vector select must be vectors"; - if (ET->getNumElements() != VT->getNumElements()) + if (ET->getElementCount() != VT->getElementCount()) return "vector select requires selected vectors to have " "the same vector length as select condition"; } else if (Op0->getType() != Type::getInt1Ty(Op0->getContext())) { diff --git a/llvm/test/CodeGen/AArch64/sve-bad-select.ll b/llvm/test/CodeGen/AArch64/sve-bad-select.ll new file mode 100644 index 0000000..2dbc4ea --- /dev/null +++ b/llvm/test/CodeGen/AArch64/sve-bad-select.ll @@ -0,0 +1,10 @@ +; RUN: not llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>&1 | FileCheck %s + +define @badsel1_nxv16i8(<16 x i1> %p, + %dst, + %a) { + %sel = select <16 x i1> %p, %a, %dst + ret %sel +} + +; CHECK: error: vector select requires selected vectors to have the same vector length as select condition