From 6f800f7333575312c9885bd14f1a6675130d8d81 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Tue, 29 Jul 2014 10:20:22 +0000 Subject: [PATCH] CodeGenPrep: fall back to MVT::Other if instruction's type isn't an EVT. The test being performed is just an approximation anyway, so it really shouldn't crash when things don't go entirely as expected. Should fix PR20474. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214177 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenPrepare.cpp | 9 ++++++--- .../CodeGenPrepare/AArch64/lit.local.cfg | 3 +++ .../CodeGenPrepare/AArch64/trunc-weird-user.ll | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 test/Transforms/CodeGenPrepare/AArch64/lit.local.cfg create mode 100644 test/Transforms/CodeGenPrepare/AArch64/trunc-weird-user.ll diff --git a/lib/CodeGen/CodeGenPrepare.cpp b/lib/CodeGen/CodeGenPrepare.cpp index d5039b2e851..8b1c3ad8eab 100644 --- a/lib/CodeGen/CodeGenPrepare.cpp +++ b/lib/CodeGen/CodeGenPrepare.cpp @@ -662,10 +662,13 @@ SinkShiftAndTruncate(BinaryOperator *ShiftI, Instruction *User, ConstantInt *CI, if (!ISDOpcode) continue; - // If the use is actually a legal node, there will not be an implicit - // truncate. + // If the use is actually a legal node, there will not be an + // implicit truncate. + // FIXME: always querying the result type is just an + // approximation; some nodes' legality is determined by the + // operand or other means. There's no good way to find out though. if (TLI.isOperationLegalOrCustom(ISDOpcode, - EVT::getEVT(TruncUser->getType()))) + EVT::getEVT(TruncUser->getType(), true))) continue; // Don't bother for PHI nodes. diff --git a/test/Transforms/CodeGenPrepare/AArch64/lit.local.cfg b/test/Transforms/CodeGenPrepare/AArch64/lit.local.cfg new file mode 100644 index 00000000000..cec29af5bbe --- /dev/null +++ b/test/Transforms/CodeGenPrepare/AArch64/lit.local.cfg @@ -0,0 +1,3 @@ +if not 'AArch64' in config.root.targets: + config.unsupported = True + diff --git a/test/Transforms/CodeGenPrepare/AArch64/trunc-weird-user.ll b/test/Transforms/CodeGenPrepare/AArch64/trunc-weird-user.ll new file mode 100644 index 00000000000..1a0878007b6 --- /dev/null +++ b/test/Transforms/CodeGenPrepare/AArch64/trunc-weird-user.ll @@ -0,0 +1,17 @@ +; RUN: opt -S -codegenprepare -mtriple=arm64-apple-ios7.0 %s | FileCheck %s + +%foo = type { i8 } + +define %foo @test_merge(i32 %in) { +; CHECK-LABEL: @test_merge + + ; CodeGenPrepare was requesting the EVT for { i8 } to determine + ; whether the insertvalue user of the trunc was legal. This + ; asserted. + +; CHECK: insertvalue %foo undef, i8 %byte, 0 + %lobit = lshr i32 %in, 31 + %byte = trunc i32 %lobit to i8 + %struct = insertvalue %foo undef, i8 %byte, 0 + ret %"foo" %struct +} -- 2.34.1