From c56c8453778cc070feee78f4a80fe85f6aa2d85c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 19 Dec 2010 18:22:06 +0000 Subject: fix another miscompile in the llvm.sadd formation logic: it wasn't checking to see if the high bits of the original add result were dead. Inserting a smaller add and zexting back to that size is not good enough. This is likely to be the fix for 8816. llvm-svn: 122177 --- llvm/test/Transforms/InstCombine/overflow.ll | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'llvm/test/Transforms/InstCombine/overflow.ll') diff --git a/llvm/test/Transforms/InstCombine/overflow.ll b/llvm/test/Transforms/InstCombine/overflow.ll index e54d315cd04..da20e2c983d 100644 --- a/llvm/test/Transforms/InstCombine/overflow.ll +++ b/llvm/test/Transforms/InstCombine/overflow.ll @@ -11,7 +11,7 @@ entry: %conv2 = sext i32 %b to i64 %add = add nsw i64 %conv2, %conv %add.off = add i64 %add, 2147483648 -; CHECK: llvm.sadd.with.overflow +; CHECK: llvm.sadd.with.overflow.i32 %0 = icmp ugt i64 %add.off, 4294967295 br i1 %0, label %if.then, label %if.end @@ -53,3 +53,24 @@ if.end: ret i32 %conv9 } +; CHECK: test3 +; This is illegal to transform because the high bits of the original add are +; live out. +define i64 @test3(i32 %a, i32 %b) nounwind ssp { +entry: + %conv = sext i32 %a to i64 + %conv2 = sext i32 %b to i64 + %add = add nsw i64 %conv2, %conv + %add.off = add i64 %add, 2147483648 +; CHECK-NOT: llvm.sadd.with.overflow + %0 = icmp ugt i64 %add.off, 4294967295 + br i1 %0, label %if.then, label %if.end + +if.then: + %call = tail call i32 (...)* @throwAnExceptionOrWhatever() nounwind + br label %if.end + +if.end: + ret i64 %add +; CHECK: ret i64 +} -- cgit v1.2.3