diff options
author | Christopher Lamb <christopher.lamb@gmail.com> | 2008-03-19 08:30:06 +0000 |
---|---|---|
committer | Christopher Lamb <christopher.lamb@gmail.com> | 2008-03-19 08:30:06 +0000 |
commit | fc5c164b753c9ca42901514c645c70e5b61c5c11 (patch) | |
tree | 323a51a31cb8a7c4e37df464dd13c8708c085f7b /lib/Target | |
parent | 9792837e758478bbdc7e1df3d1f1d304eee59011 (diff) | |
download | external_llvm-fc5c164b753c9ca42901514c645c70e5b61c5c11.zip external_llvm-fc5c164b753c9ca42901514c645c70e5b61c5c11.tar.gz external_llvm-fc5c164b753c9ca42901514c645c70e5b61c5c11.tar.bz2 |
Fix X86's isTruncateFree to not claim that truncate to i1 is free. This fixes Bill's testcase that failed for r48491.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48542 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/X86/README.txt | 44 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelLowering.cpp | 4 |
2 files changed, 2 insertions, 46 deletions
diff --git a/lib/Target/X86/README.txt b/lib/Target/X86/README.txt index 1588b49..ceda932 100644 --- a/lib/Target/X86/README.txt +++ b/lib/Target/X86/README.txt @@ -1647,47 +1647,3 @@ The coalescer could coalesce "edx" with "eax" to avoid the movl in LBB1_2 if it commuted the addl in LBB1_1. //===---------------------------------------------------------------------===// - -These two functions perform identical operations: - -define i32 @test(i32 %f12) { - %tmp7.25 = lshr i32 %f12, 16 - %tmp7.26 = trunc i32 %tmp7.25 to i8 - %tmp78.2 = sext i8 %tmp7.26 to i32 - ret i32 %tmp78.2 -} - -define i32 @test2(i32 %f12) { - %f11 = shl i32 %f12, 8 - %tmp7.25 = ashr i32 %f11, 24 - ret i32 %tmp7.25 -} - -but the first compiles into significantly better code on x86-32: - -_test: - movsbl 6(%esp), %eax - ret -_test2: - movl 4(%esp), %eax - shll $8, %eax - sarl $24, %eax - ret - -and on x86-64: - -_test: - shrl $16, %edi - movsbl %dil, %eax - ret -_test2: - shll $8, %edi - movl %edi, %eax - sarl $24, %eax - ret - -I would like instcombine to canonicalize the first into the second (since it is -shorter and doesn't involve type width changes) but the x86 backend needs to do -the right thing with the later sequence first. - -//===---------------------------------------------------------------------===// diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 5a05aba..93fb802 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -5662,7 +5662,7 @@ bool X86TargetLowering::isTruncateFree(const Type *Ty1, const Type *Ty2) const { return false; unsigned NumBits1 = Ty1->getPrimitiveSizeInBits(); unsigned NumBits2 = Ty2->getPrimitiveSizeInBits(); - if (NumBits1 <= NumBits2) + if (NumBits1 <= NumBits2 || NumBits2 < 8) return false; return Subtarget->is64Bit() || NumBits1 < 64; } @@ -5673,7 +5673,7 @@ bool X86TargetLowering::isTruncateFree(MVT::ValueType VT1, return false; unsigned NumBits1 = MVT::getSizeInBits(VT1); unsigned NumBits2 = MVT::getSizeInBits(VT2); - if (NumBits1 <= NumBits2) + if (NumBits1 <= NumBits2 || NumBits2 < 8) return false; return Subtarget->is64Bit() || NumBits1 < 64; } |