Shuxin Yang 0a46bf13a3 This change is to fix rdar://12571717 which is about assertion in Reassociate pass.
The assertion is trigged when the Reassociater tries to transform expression
     ... + 2 * n * 3 + 2 * m + ...
  into:
     ... + 2 * (n*3 + m).

In the process of the transformation, a helper routine folds the constant 2*3 into 6,
confusing optimizer which is trying the to eliminate the common factor 2, and cannot
find 2 any more. 

Review is pending. But I'd like commit first in order to help those who are waiting 
for this fix. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167740 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-12 19:34:11 +00:00

14 lines
315 B
LLVM

; RUN: opt -S -reassociate < %s | FileCheck %s
; t=-a; retval = t*7|t => t-a; retval => a*-7|t
define i32 @mulneg(i32 %a) nounwind uwtable ssp {
entry:
%sub = sub nsw i32 0, %a
%tmp1 = mul i32 %sub, 7
%tmp2 = xor i32 %sub, %tmp1
ret i32 %tmp2
; CHECK: entry
; CHECK: %tmp1 = mul i32 %a, -7
; CHECK: ret
}