mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-16 11:30:51 +00:00
5cb8ab5b5a
Adds simple logical canonicalization of assumption intrinsics to instcombine, currently: - invariant(a && b) -> invariant(a); invariant(b) - invariant(!(a || b)) -> invariant(!a); invariant(!b) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213977 91177308-0d34-0410-b5e6-96231b3b80d8
44 lines
1007 B
LLVM
44 lines
1007 B
LLVM
; RUN: opt < %s -instcombine -S | FileCheck %s
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
; Function Attrs: nounwind
|
|
declare void @llvm.assume(i1) #1
|
|
|
|
; Function Attrs: nounwind uwtable
|
|
define i32 @can1(i1 %a, i1 %b, i1 %c) {
|
|
entry:
|
|
%and1 = and i1 %a, %b
|
|
%and = and i1 %and1, %c
|
|
tail call void @llvm.assume(i1 %and)
|
|
|
|
; CHECK-LABEL: @can1
|
|
; CHECK: call void @llvm.assume(i1 %a)
|
|
; CHECK: call void @llvm.assume(i1 %b)
|
|
; CHECK: call void @llvm.assume(i1 %c)
|
|
; CHECK: ret i32
|
|
|
|
ret i32 5
|
|
}
|
|
|
|
; Function Attrs: nounwind uwtable
|
|
define i32 @can2(i1 %a, i1 %b, i1 %c) {
|
|
entry:
|
|
%v = or i1 %a, %b
|
|
%w = xor i1 %v, 1
|
|
tail call void @llvm.assume(i1 %w)
|
|
|
|
; CHECK-LABEL: @can2
|
|
; CHECK: %[[V1:[^ ]+]] = xor i1 %a, true
|
|
; CHECK: call void @llvm.assume(i1 %[[V1]])
|
|
; CHECK: %[[V2:[^ ]+]] = xor i1 %b, true
|
|
; CHECK: call void @llvm.assume(i1 %[[V2]])
|
|
; CHECK: ret i32
|
|
|
|
ret i32 5
|
|
}
|
|
|
|
attributes #0 = { nounwind uwtable }
|
|
attributes #1 = { nounwind }
|
|
|