mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
[GVN] Intersect the IR flags when CSE'ing two instructions
We performed a simple, but incomplete, intersection when it came time to CSE instructions. It didn't handle, for example, the 'exact' flag. This fixes PR23922. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240595 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e40e848767
commit
12bb40b2ab
@ -1783,13 +1783,9 @@ static void patchReplacementInstruction(Instruction *I, Value *Repl) {
|
||||
// being replaced.
|
||||
BinaryOperator *Op = dyn_cast<BinaryOperator>(I);
|
||||
BinaryOperator *ReplOp = dyn_cast<BinaryOperator>(Repl);
|
||||
if (Op && ReplOp && isa<OverflowingBinaryOperator>(Op) &&
|
||||
isa<OverflowingBinaryOperator>(ReplOp)) {
|
||||
if (ReplOp->hasNoSignedWrap() && !Op->hasNoSignedWrap())
|
||||
ReplOp->setHasNoSignedWrap(false);
|
||||
if (ReplOp->hasNoUnsignedWrap() && !Op->hasNoUnsignedWrap())
|
||||
ReplOp->setHasNoUnsignedWrap(false);
|
||||
}
|
||||
if (Op && ReplOp)
|
||||
ReplOp->andIRFlags(Op);
|
||||
|
||||
if (Instruction *ReplInst = dyn_cast<Instruction>(Repl)) {
|
||||
// FIXME: If both the original and replacement value are part of the
|
||||
// same control-flow region (meaning that the execution of one
|
||||
|
@ -77,3 +77,17 @@ define i32 @test7(i32 %x, i32 %y) {
|
||||
%foo = add i32 %add1, %add2
|
||||
ret i32 %foo
|
||||
}
|
||||
|
||||
declare void @mumble(i2, i2)
|
||||
|
||||
define void @test8(i2 %x) {
|
||||
; CHECK-LABEL: @test8(
|
||||
; CHECK: %[[ashr:.*]] = ashr i2 %x, 1
|
||||
; CHECK-NEXT: call void @mumble(i2 %[[ashr]], i2 %[[ashr]])
|
||||
; CHECK-NEXT: ret void
|
||||
|
||||
%ashr0 = ashr exact i2 %x, 1
|
||||
%ashr1 = ashr i2 %x, 1
|
||||
call void @mumble(i2 %ashr0, i2 %ashr1)
|
||||
ret void
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user