mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-06 09:54:49 +00:00
replace the operands of expressions with only one use with undef and generate a new expression for the original without using RAUW to update the original. Thus any copies of the original expression held in a vector may end up referring to some bogus value - and using a ValueHandle won't help since there is no RAUW. There is already a mechanism for getting the effect of recursion non-recursively: adding the value to be recursed on to RedoInsts. But it wasn't being used systematically. Have various places where recursion had snuck in at some point use the RedoInsts mechanism instead. Fixes PR12169. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156379 91177308-0d34-0410-b5e6-96231b3b80d8
32 lines
830 B
LLVM
32 lines
830 B
LLVM
; RUN: opt < %s -reassociate -S | FileCheck %s
|
|
|
|
define i64 @multistep1(i64 %a, i64 %b, i64 %c) {
|
|
; Check that a*a*b+a*a*c is turned into a*(a*(b+c)).
|
|
; CHECK: @multistep1
|
|
%t0 = mul i64 %a, %b
|
|
%t1 = mul i64 %a, %t0 ; a*(a*b)
|
|
%t2 = mul i64 %a, %c
|
|
%t3 = mul i64 %a, %t2 ; a*(a*c)
|
|
%t4 = add i64 %t1, %t3
|
|
; CHECK-NEXT: add i64 %c, %b
|
|
; CHECK-NEXT: mul i64 %tmp{{.*}}, %a
|
|
; CHECK-NEXT: mul i64 %tmp{{.*}}, %a
|
|
; CHECK-NEXT: ret
|
|
ret i64 %t4
|
|
}
|
|
|
|
define i64 @multistep2(i64 %a, i64 %b, i64 %c, i64 %d) {
|
|
; Check that a*b+a*c+d is turned into a*(b+c)+d.
|
|
; CHECK: @multistep2
|
|
%t0 = mul i64 %a, %b
|
|
%t1 = mul i64 %a, %c
|
|
%t2 = add i64 %t1, %d ; a*c+d
|
|
%t3 = add i64 %t0, %t2 ; a*b+(a*c+d)
|
|
; CHECK-NEXT: add i64 %c, %b
|
|
; CHECK-NEXT: mul i64 %tmp{{.*}}, %a
|
|
; CHECK-NEXT: add i64 %tmp{{.*}}, %d
|
|
; CHECK-NEXT: ret
|
|
ret i64 %t3
|
|
}
|
|
|