From 07c26ee87e4060f487867f1e283801bd8ced62d1 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 31 Mar 2009 01:38:29 +0000 Subject: [PATCH] Fix live-out reg logic to not insert over-aggressive AssertZExt instructions. This fixes lua. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68083 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../SelectionDAG/SelectionDAGBuild.cpp | 6 +++--- test/CodeGen/X86/live-out-reg-info.ll | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 test/CodeGen/X86/live-out-reg-info.ll diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp index 4bf90508e9f..ba59906b6da 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp @@ -4587,15 +4587,15 @@ SDValue RegsForValue::getCopyFromRegs(SelectionDAG &DAG, DebugLoc dl, isSExt = false, FromVT = MVT::i1; // ASSERT ZEXT 1 else if (NumSignBits > RegSize-8) isSExt = true, FromVT = MVT::i8; // ASSERT SEXT 8 - else if (NumZeroBits >= RegSize-9) + else if (NumZeroBits >= RegSize-8) isSExt = false, FromVT = MVT::i8; // ASSERT ZEXT 8 else if (NumSignBits > RegSize-16) isSExt = true, FromVT = MVT::i16; // ASSERT SEXT 16 - else if (NumZeroBits >= RegSize-17) + else if (NumZeroBits >= RegSize-16) isSExt = false, FromVT = MVT::i16; // ASSERT ZEXT 16 else if (NumSignBits > RegSize-32) isSExt = true, FromVT = MVT::i32; // ASSERT SEXT 32 - else if (NumZeroBits >= RegSize-33) + else if (NumZeroBits >= RegSize-32) isSExt = false, FromVT = MVT::i32; // ASSERT ZEXT 32 if (FromVT != MVT::Other) { diff --git a/test/CodeGen/X86/live-out-reg-info.ll b/test/CodeGen/X86/live-out-reg-info.ll new file mode 100644 index 00000000000..b6fb7dfc72c --- /dev/null +++ b/test/CodeGen/X86/live-out-reg-info.ll @@ -0,0 +1,20 @@ +; RUN: llvm-as < %s | llc -march=x86-64 | grep testl + +; Make sure dagcombine doesn't eliminate the comparison due +; to an off-by-one bug with ComputeMaskedBits information. + +declare void @qux() + +define void @foo(i32 %a) { + %t0 = lshr i32 %a, 23 + br label %next +next: + %t1 = and i32 %t0, 256 + %t2 = icmp eq i32 %t1, 0 + br i1 %t2, label %true, label %false +true: + call void @qux() + ret void +false: + ret void +}