mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-16 00:33:10 +00:00
EarlyCSE should ignore calls to @llvm.assume
EarlyCSE uses a simple generation scheme for handling memory-based dependencies, and calls to @llvm.assume (which are marked as writing to memory to ensure the preservation of control dependencies) disturb that scheme unnecessarily. Skipping calls to @llvm.assume is legal, and the alternative (adding AA calls in EarlyCSE) is likely undesirable (we have GVN for that). Fixes PR21448. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221175 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fbd383c93c
commit
f16d6b1ff1
@ -21,6 +21,8 @@
|
|||||||
#include "llvm/IR/DataLayout.h"
|
#include "llvm/IR/DataLayout.h"
|
||||||
#include "llvm/IR/Dominators.h"
|
#include "llvm/IR/Dominators.h"
|
||||||
#include "llvm/IR/Instructions.h"
|
#include "llvm/IR/Instructions.h"
|
||||||
|
#include "llvm/IR/IntrinsicInst.h"
|
||||||
|
#include "llvm/IR/PatternMatch.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/RecyclingAllocator.h"
|
#include "llvm/Support/RecyclingAllocator.h"
|
||||||
@ -28,6 +30,7 @@
|
|||||||
#include "llvm/Transforms/Utils/Local.h"
|
#include "llvm/Transforms/Utils/Local.h"
|
||||||
#include <deque>
|
#include <deque>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
using namespace llvm::PatternMatch;
|
||||||
|
|
||||||
#define DEBUG_TYPE "early-cse"
|
#define DEBUG_TYPE "early-cse"
|
||||||
|
|
||||||
@ -435,6 +438,15 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip assume intrinsics, they don't really have side effects (although
|
||||||
|
// they're marked as such to ensure preservation of control dependencies),
|
||||||
|
// and this pass will not disturb any of the assumption's control
|
||||||
|
// dependencies.
|
||||||
|
if (match(Inst, m_Intrinsic<Intrinsic::assume>())) {
|
||||||
|
DEBUG(dbgs() << "EarlyCSE skipping assumption: " << *Inst << '\n');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// If the instruction can be simplified (e.g. X+0 = X) then replace it with
|
// If the instruction can be simplified (e.g. X+0 = X) then replace it with
|
||||||
// its simpler value.
|
// its simpler value.
|
||||||
if (Value *V = SimplifyInstruction(Inst, DL, TLI, DT, AT)) {
|
if (Value *V = SimplifyInstruction(Inst, DL, TLI, DT, AT)) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
; RUN: opt < %s -S -early-cse | FileCheck %s
|
; RUN: opt < %s -S -early-cse | FileCheck %s
|
||||||
|
|
||||||
|
declare void @llvm.assume(i1) nounwind
|
||||||
|
|
||||||
; CHECK-LABEL: @test1(
|
; CHECK-LABEL: @test1(
|
||||||
define void @test1(i8 %V, i32 *%P) {
|
define void @test1(i8 %V, i32 *%P) {
|
||||||
@ -42,6 +43,16 @@ define i32 @test2(i32 *%P) {
|
|||||||
; CHECK: ret i32 0
|
; CHECK: ret i32 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; CHECK-LABEL: @test2a(
|
||||||
|
define i32 @test2a(i32 *%P, i1 %b) {
|
||||||
|
%V1 = load i32* %P
|
||||||
|
tail call void @llvm.assume(i1 %b)
|
||||||
|
%V2 = load i32* %P
|
||||||
|
%Diff = sub i32 %V1, %V2
|
||||||
|
ret i32 %Diff
|
||||||
|
; CHECK: ret i32 0
|
||||||
|
}
|
||||||
|
|
||||||
;; Cross block load value numbering.
|
;; Cross block load value numbering.
|
||||||
; CHECK-LABEL: @test3(
|
; CHECK-LABEL: @test3(
|
||||||
define i32 @test3(i32 *%P, i1 %Cond) {
|
define i32 @test3(i32 *%P, i1 %Cond) {
|
||||||
@ -58,6 +69,22 @@ F:
|
|||||||
; CHECK: ret i32 0
|
; CHECK: ret i32 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; CHECK-LABEL: @test3a(
|
||||||
|
define i32 @test3a(i32 *%P, i1 %Cond, i1 %b) {
|
||||||
|
%V1 = load i32* %P
|
||||||
|
br i1 %Cond, label %T, label %F
|
||||||
|
T:
|
||||||
|
store i32 4, i32* %P
|
||||||
|
ret i32 42
|
||||||
|
F:
|
||||||
|
tail call void @llvm.assume(i1 %b)
|
||||||
|
%V2 = load i32* %P
|
||||||
|
%Diff = sub i32 %V1, %V2
|
||||||
|
ret i32 %Diff
|
||||||
|
; CHECK: F:
|
||||||
|
; CHECK: ret i32 0
|
||||||
|
}
|
||||||
|
|
||||||
;; Cross block load value numbering stops when stores happen.
|
;; Cross block load value numbering stops when stores happen.
|
||||||
; CHECK-LABEL: @test4(
|
; CHECK-LABEL: @test4(
|
||||||
define i32 @test4(i32 *%P, i1 %Cond) {
|
define i32 @test4(i32 *%P, i1 %Cond) {
|
||||||
@ -97,6 +124,15 @@ define i32 @test6(i32 *%P) {
|
|||||||
; CHECK: ret i32 42
|
; CHECK: ret i32 42
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; CHECK-LABEL: @test6a(
|
||||||
|
define i32 @test6a(i32 *%P, i1 %b) {
|
||||||
|
store i32 42, i32* %P
|
||||||
|
tail call void @llvm.assume(i1 %b)
|
||||||
|
%V1 = load i32* %P
|
||||||
|
ret i32 %V1
|
||||||
|
; CHECK: ret i32 42
|
||||||
|
}
|
||||||
|
|
||||||
;; Trivial dead store elimination.
|
;; Trivial dead store elimination.
|
||||||
; CHECK-LABEL: @test7(
|
; CHECK-LABEL: @test7(
|
||||||
define void @test7(i32 *%P) {
|
define void @test7(i32 *%P) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user