diff options
Diffstat (limited to 'test/Transforms/Reassociate')
| -rw-r--r-- | test/Transforms/Reassociate/pr12245.ll | 44 | ||||
| -rw-r--r-- | test/Transforms/Reassociate/xor_reassoc.ll | 27 |
2 files changed, 47 insertions, 24 deletions
diff --git a/test/Transforms/Reassociate/pr12245.ll b/test/Transforms/Reassociate/pr12245.ll index 84098bdb006b..e9b5355cceb1 100644 --- a/test/Transforms/Reassociate/pr12245.ll +++ b/test/Transforms/Reassociate/pr12245.ll @@ -6,36 +6,36 @@ define i32 @fn2() nounwind uwtable ssp { entry: - %0 = load i32* @a, align 4, !tbaa !0 + %0 = load i32* @a, align 4 %dec = add nsw i32 %0, -1 - store i32 %dec, i32* @a, align 4, !tbaa !0 - %1 = load i32* @d, align 4, !tbaa !0 + store i32 %dec, i32* @a, align 4 + %1 = load i32* @d, align 4 %sub = sub nsw i32 %dec, %1 - store i32 %sub, i32* @d, align 4, !tbaa !0 - %2 = load i32* @a, align 4, !tbaa !0 + store i32 %sub, i32* @d, align 4 + %2 = load i32* @a, align 4 %dec1 = add nsw i32 %2, -1 - store i32 %dec1, i32* @a, align 4, !tbaa !0 - %3 = load i32* @d, align 4, !tbaa !0 + store i32 %dec1, i32* @a, align 4 + %3 = load i32* @d, align 4 %sub2 = sub nsw i32 %dec1, %3 - store i32 %sub2, i32* @d, align 4, !tbaa !0 - %4 = load i32* @a, align 4, !tbaa !0 + store i32 %sub2, i32* @d, align 4 + %4 = load i32* @a, align 4 %dec3 = add nsw i32 %4, -1 - store i32 %dec3, i32* @a, align 4, !tbaa !0 - %5 = load i32* @d, align 4, !tbaa !0 + store i32 %dec3, i32* @a, align 4 + %5 = load i32* @d, align 4 %sub4 = sub nsw i32 %dec3, %5 - store i32 %sub4, i32* @d, align 4, !tbaa !0 - %6 = load i32* @a, align 4, !tbaa !0 + store i32 %sub4, i32* @d, align 4 + %6 = load i32* @a, align 4 %dec5 = add nsw i32 %6, -1 - store i32 %dec5, i32* @a, align 4, !tbaa !0 - %7 = load i32* @d, align 4, !tbaa !0 + store i32 %dec5, i32* @a, align 4 + %7 = load i32* @d, align 4 %sub6 = sub nsw i32 %dec5, %7 - store i32 %sub6, i32* @d, align 4, !tbaa !0 - %8 = load i32* @a, align 4, !tbaa !0 + store i32 %sub6, i32* @d, align 4 + %8 = load i32* @a, align 4 %dec7 = add nsw i32 %8, -1 - store i32 %dec7, i32* @a, align 4, !tbaa !0 - %9 = load i32* @d, align 4, !tbaa !0 + store i32 %dec7, i32* @a, align 4 + %9 = load i32* @d, align 4 %sub8 = sub nsw i32 %dec7, %9 - store i32 %sub8, i32* @d, align 4, !tbaa !0 + store i32 %sub8, i32* @d, align 4 ret i32 0 } @@ -44,7 +44,3 @@ entry: %call = call i32 @fn2() ret i32 %call } - -!0 = metadata !{metadata !"int", metadata !1} -!1 = metadata !{metadata !"omnipotent char", metadata !2} -!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/test/Transforms/Reassociate/xor_reassoc.ll b/test/Transforms/Reassociate/xor_reassoc.ll index d371a9b5b68f..b9353c7f81fe 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 +} |
