mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 05:25:47 +00:00
scalarizePHI needs to insert the next ExtractElement in the same block
as the BinaryOperator, *not* in the block where the IRBuilder is currently inserting into. Fixes a bug where scalarizePHI would create instructions that would not dominate all uses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182639 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -146,8 +146,10 @@ Instruction *InstCombiner::scalarizePHI(ExtractElementInst &EI, PHINode *PN) {
|
|||||||
// vector operand.
|
// vector operand.
|
||||||
BinaryOperator *B0 = cast<BinaryOperator>(PHIUser);
|
BinaryOperator *B0 = cast<BinaryOperator>(PHIUser);
|
||||||
unsigned opId = (B0->getOperand(0) == PN) ? 1: 0;
|
unsigned opId = (B0->getOperand(0) == PN) ? 1: 0;
|
||||||
Value *Op = Builder->CreateExtractElement(
|
Value *Op = InsertNewInstWith(
|
||||||
B0->getOperand(opId), Elt, B0->getOperand(opId)->getName()+".Elt");
|
ExtractElementInst::Create(B0->getOperand(opId), Elt,
|
||||||
|
B0->getOperand(opId)->getName() + ".Elt"),
|
||||||
|
*B0);
|
||||||
Value *newPHIUser = InsertNewInstWith(
|
Value *newPHIUser = InsertNewInstWith(
|
||||||
BinaryOperator::Create(B0->getOpcode(), scalarPHI,Op),
|
BinaryOperator::Create(B0->getOpcode(), scalarPHI,Op),
|
||||||
*B0);
|
*B0);
|
||||||
|
@@ -25,3 +25,28 @@ ret:
|
|||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define i1 @g(<3 x i32> %input_2) {
|
||||||
|
; CHECK: extractelement
|
||||||
|
entry:
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
for.cond:
|
||||||
|
; CHECK: phi i32
|
||||||
|
%input_2.addr.0 = phi <3 x i32> [ %input_2, %entry ], [ %div45, %for.body ]
|
||||||
|
%input_1.addr.1 = phi <3 x i32> [ undef, %entry ], [ %dec43, %for.body ]
|
||||||
|
br i1 undef, label %for.end, label %for.body
|
||||||
|
|
||||||
|
; CHECK extractelement
|
||||||
|
for.body:
|
||||||
|
%dec43 = add <3 x i32> %input_1.addr.1, <i32 -1, i32 -1, i32 -1>
|
||||||
|
%sub44 = sub <3 x i32> zeroinitializer, %dec43
|
||||||
|
%div45 = sdiv <3 x i32> %input_2.addr.0, %sub44
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
for.end:
|
||||||
|
%0 = extractelement <3 x i32> %input_2.addr.0, i32 0
|
||||||
|
%.89 = select i1 false, i32 0, i32 %0
|
||||||
|
%tobool313 = icmp eq i32 %.89, 0
|
||||||
|
ret i1 %tobool313
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user