mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-21 00:32:23 +00:00
5057f38141
fairly systematic way in instcombine. Some of these cases were already dealt with, in which case I removed the existing code. The case of Add has a bunch of funky logic which covers some of this plus a few variants (considers shifts to be a form of multiplication), which I didn't touch. The simplification performed is: A*B+A*C -> A*(B+C). The improvement is to do this in cases that were not already handled [such as A*B-A*C -> A*(B-C), which was reported on the mailing list], and also to do it more often by not checking for "only one use" if "B+C" simplifies. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120024 91177308-0d34-0410-b5e6-96231b3b80d8
12 lines
285 B
LLVM
12 lines
285 B
LLVM
; RUN: opt < %s -instcombine -S | FileCheck %s
|
|
define i32 @foo(i32 %x, i32 %y) {
|
|
; CHECK: @foo
|
|
%add = add nsw i32 %y, %x
|
|
%mul = mul nsw i32 %add, %y
|
|
%square = mul nsw i32 %y, %y
|
|
%res = sub i32 %mul, %square
|
|
; CHECK: %res = mul i32 %x, %y
|
|
ret i32 %res
|
|
; CHECK: ret i32 %res
|
|
}
|