mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
7a6aa1a391
exact/nsw/nuw shifts and have instcombine infer them when it can prove that the relevant properties are true for a given shift without them. Also, a variety of refactoring to use the new patternmatch logic thrown in for good luck. I believe that this takes care of a bunch of related code quality issues attached to PR8862. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125267 91177308-0d34-0410-b5e6-96231b3b80d8
40 lines
793 B
LLVM
40 lines
793 B
LLVM
; RUN: opt < %s -instcombine -S | FileCheck %s
|
|
|
|
; CHECK: @sub1
|
|
; CHECK: %y = sub i32 0, %x
|
|
; CHECK: %z = sdiv i32 %y, 337
|
|
; CHECK: ret i32 %z
|
|
define i32 @sub1(i32 %x) {
|
|
%y = sub i32 0, %x
|
|
%z = sdiv i32 %y, 337
|
|
ret i32 %z
|
|
}
|
|
|
|
; CHECK: @sub2
|
|
; CHECK: %z = sdiv i32 %x, -337
|
|
; CHECK: ret i32 %z
|
|
define i32 @sub2(i32 %x) {
|
|
%y = sub nsw i32 0, %x
|
|
%z = sdiv i32 %y, 337
|
|
ret i32 %z
|
|
}
|
|
|
|
; CHECK: @shl_icmp
|
|
; CHECK: %B = icmp eq i64 %X, 0
|
|
; CHECK: ret i1 %B
|
|
define i1 @shl_icmp(i64 %X) nounwind {
|
|
%A = shl nuw i64 %X, 2 ; X/4
|
|
%B = icmp eq i64 %A, 0
|
|
ret i1 %B
|
|
}
|
|
|
|
; CHECK: @shl1
|
|
; CHECK: %B = shl nuw nsw i64 %A, 8
|
|
; CHECK: ret i64 %B
|
|
define i64 @shl1(i64 %X, i64* %P) nounwind {
|
|
%A = and i64 %X, 312
|
|
store i64 %A, i64* %P ; multiple uses of A.
|
|
%B = shl i64 %A, 8
|
|
ret i64 %B
|
|
}
|