diff options
author | Shuxin Yang <shuxin.llvm@gmail.com> | 2013-04-27 18:02:12 +0000 |
---|---|---|
committer | Shuxin Yang <shuxin.llvm@gmail.com> | 2013-04-27 18:02:12 +0000 |
commit | 4d4c54d29ff911f59fe2be1a31331dbcbb741f5f (patch) | |
tree | 7462985c701c756423fce2663a8820dee00f7223 /test/Transforms | |
parent | 595dd5af1438141dde4f19225d5b57170c651731 (diff) | |
download | external_llvm-4d4c54d29ff911f59fe2be1a31331dbcbb741f5f.zip external_llvm-4d4c54d29ff911f59fe2be1a31331dbcbb741f5f.tar.gz external_llvm-4d4c54d29ff911f59fe2be1a31331dbcbb741f5f.tar.bz2 |
Fix a XOR reassociation bug.
When Reassociator optimize "(x | C1)" ^ "(X & C2)", it may swap the two
subexpressions, however, it forgot to swap cached constants (of C1 and C2)
accordingly.
rdar://13739160
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180676 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r-- | test/Transforms/Reassociate/xor_reassoc.ll | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/Transforms/Reassociate/xor_reassoc.ll b/test/Transforms/Reassociate/xor_reassoc.ll index d371a9b..b9353c7 100644 --- a/test/Transforms/Reassociate/xor_reassoc.ll +++ b/test/Transforms/Reassociate/xor_reassoc.ll @@ -164,3 +164,30 @@ define void @xor_bug1() { %3 = and i64 undef, %2 ret void } + +; The bug was that when the compiler optimize "(x | c1)" ^ "(x & c2)", it may +; swap the two xor-subexpressions if they are not in canoninical order; however, +; when optimizer swaps two sub-expressions, if forgot to swap the cached value +; of c1 and c2 accordingly, hence cause the problem. +; +define i32 @xor_bug2(i32, i32, i32, i32) { + %5 = mul i32 %0, 123 + %6 = add i32 %2, 24 + %7 = add i32 %1, 8 + %8 = and i32 %1, 3456789 + %9 = or i32 %8, 4567890 + %10 = and i32 %1, 543210987 + %11 = or i32 %1, 891034567 + %12 = and i32 %2, 255 + %13 = xor i32 %9, %10 + %14 = xor i32 %11, %13 + %15 = xor i32 %5, %14 + %16 = and i32 %3, 255 + %17 = xor i32 %16, 42 + %18 = add i32 %6, %7 + %19 = add i32 %18, %12 + %20 = add i32 %19, %15 + ret i32 %20 +;CHECK: @xor_bug2 +;CHECK: xor i32 %5, 891034567 +} |