mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +00:00
[X86] Never hoist the shift value of a shift instruction.
There is no need to check if we want to hoist the immediate value of an shift instruction. Simply return TCC_Free right away. This change is like r206101, but for X86. rdar://problem/16190769 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207692 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -956,15 +956,19 @@ unsigned X86TTI::getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
|
|||||||
case Instruction::SDiv:
|
case Instruction::SDiv:
|
||||||
case Instruction::URem:
|
case Instruction::URem:
|
||||||
case Instruction::SRem:
|
case Instruction::SRem:
|
||||||
case Instruction::Shl:
|
|
||||||
case Instruction::LShr:
|
|
||||||
case Instruction::AShr:
|
|
||||||
case Instruction::And:
|
case Instruction::And:
|
||||||
case Instruction::Or:
|
case Instruction::Or:
|
||||||
case Instruction::Xor:
|
case Instruction::Xor:
|
||||||
case Instruction::ICmp:
|
case Instruction::ICmp:
|
||||||
ImmIdx = 1;
|
ImmIdx = 1;
|
||||||
break;
|
break;
|
||||||
|
// Always return TCC_Free for the shift value of a shift instruction.
|
||||||
|
case Instruction::Shl:
|
||||||
|
case Instruction::LShr:
|
||||||
|
case Instruction::AShr:
|
||||||
|
if (Idx == 1)
|
||||||
|
return TCC_Free;
|
||||||
|
break;
|
||||||
case Instruction::Trunc:
|
case Instruction::Trunc:
|
||||||
case Instruction::ZExt:
|
case Instruction::ZExt:
|
||||||
case Instruction::SExt:
|
case Instruction::SExt:
|
||||||
|
@@ -31,6 +31,8 @@ target triple = "i386-apple-macosx10.9"
|
|||||||
; Function Attrs: nounwind optsize ssp
|
; Function Attrs: nounwind optsize ssp
|
||||||
define fastcc void @__XXX1(%struct.A* %ht) #0 {
|
define fastcc void @__XXX1(%struct.A* %ht) #0 {
|
||||||
entry:
|
entry:
|
||||||
|
%const72 = bitcast i128 72 to i128
|
||||||
|
%const3 = bitcast i128 3 to i128
|
||||||
switch i32 undef, label %if.end196 [
|
switch i32 undef, label %if.end196 [
|
||||||
i32 1, label %sw.bb.i
|
i32 1, label %sw.bb.i
|
||||||
i32 3, label %sw.bb2.i
|
i32 3, label %sw.bb2.i
|
||||||
@@ -39,13 +41,13 @@ entry:
|
|||||||
sw.bb.i: ; preds = %entry
|
sw.bb.i: ; preds = %entry
|
||||||
%call.i.i.i = tail call i32 undef(%struct.A* %ht, i8 zeroext 22, i32 undef, i32 0, %struct.D* undef)
|
%call.i.i.i = tail call i32 undef(%struct.A* %ht, i8 zeroext 22, i32 undef, i32 0, %struct.D* undef)
|
||||||
%bf.load.i.i = load i128* undef, align 4
|
%bf.load.i.i = load i128* undef, align 4
|
||||||
%bf.lshr.i.i = lshr i128 %bf.load.i.i, 72
|
%bf.lshr.i.i = lshr i128 %bf.load.i.i, %const72
|
||||||
%shl1.i.i = shl nuw nsw i128 %bf.lshr.i.i, 8
|
%shl1.i.i = shl nuw nsw i128 %bf.lshr.i.i, 8
|
||||||
%shl.i.i = trunc i128 %shl1.i.i to i32
|
%shl.i.i = trunc i128 %shl1.i.i to i32
|
||||||
br i1 undef, label %cond.false10.i.i, label %__XXX2.exit.i.i
|
br i1 undef, label %cond.false10.i.i, label %__XXX2.exit.i.i
|
||||||
|
|
||||||
__XXX2.exit.i.i: ; preds = %sw.bb.i
|
__XXX2.exit.i.i: ; preds = %sw.bb.i
|
||||||
%extract11.i.i.i = lshr i128 %bf.load.i.i, 3
|
%extract11.i.i.i = lshr i128 %bf.load.i.i, %const3
|
||||||
%extract.t12.i.i.i = trunc i128 %extract11.i.i.i to i32
|
%extract.t12.i.i.i = trunc i128 %extract11.i.i.i to i32
|
||||||
%bf.cast7.i.i.i = and i32 %extract.t12.i.i.i, 3
|
%bf.cast7.i.i.i = and i32 %extract.t12.i.i.i, 3
|
||||||
%arrayidx.i.i.i = getelementptr inbounds %struct.A* %ht, i32 0, i32 3, i32 %bf.cast7.i.i.i
|
%arrayidx.i.i.i = getelementptr inbounds %struct.A* %ht, i32 0, i32 3, i32 %bf.cast7.i.i.i
|
||||||
@@ -69,11 +71,11 @@ for.body.i.i: ; preds = %for.body.i.i, %cond
|
|||||||
br i1 %or.cond, label %for.body.i.i, label %if.end196
|
br i1 %or.cond, label %for.body.i.i, label %if.end196
|
||||||
|
|
||||||
sw.bb2.i: ; preds = %entry
|
sw.bb2.i: ; preds = %entry
|
||||||
%bf.lshr.i85.i = lshr i128 undef, 72
|
%bf.lshr.i85.i = lshr i128 undef, %const72
|
||||||
br i1 undef, label %if.end196, label %__XXX2.exit.i95.i
|
br i1 undef, label %if.end196, label %__XXX2.exit.i95.i
|
||||||
|
|
||||||
__XXX2.exit.i95.i: ; preds = %sw.bb2.i
|
__XXX2.exit.i95.i: ; preds = %sw.bb2.i
|
||||||
%extract11.i.i91.i = lshr i128 undef, 3
|
%extract11.i.i91.i = lshr i128 undef, %const3
|
||||||
br label %if.end196
|
br label %if.end196
|
||||||
|
|
||||||
if.end196: ; preds = %__XXX2.exit.i95.i, %sw.bb2.i, %for.body.i.i, %cond.end12.i.i, %entry
|
if.end196: ; preds = %__XXX2.exit.i95.i, %sw.bb2.i, %for.body.i.i, %cond.end12.i.i, %entry
|
||||||
|
18
test/Transforms/ConstantHoisting/X86/large-immediate.ll
Normal file
18
test/Transforms/ConstantHoisting/X86/large-immediate.ll
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
; RUN: opt -mtriple=x86_64-darwin-unknown -S -consthoist < %s | FileCheck %s
|
||||||
|
|
||||||
|
define i128 @test1(i128 %a) nounwind {
|
||||||
|
; CHECK-LABEL: test1
|
||||||
|
; CHECK: %const = bitcast i128 12297829382473034410122878 to i128
|
||||||
|
%1 = add i128 %a, 12297829382473034410122878
|
||||||
|
%2 = add i128 %1, 12297829382473034410122878
|
||||||
|
ret i128 %2
|
||||||
|
}
|
||||||
|
|
||||||
|
; Check that we don't hoist the shift value of a shift instruction.
|
||||||
|
define i512 @test2(i512 %a) nounwind {
|
||||||
|
; CHECK-LABEL: test2
|
||||||
|
; CHECK-NOT: %const = bitcast i512 504 to i512
|
||||||
|
%1 = shl i512 %a, 504
|
||||||
|
%2 = ashr i512 %1, 504
|
||||||
|
ret i512 %2
|
||||||
|
}
|
Reference in New Issue
Block a user