diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-08-14 03:41:33 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-08-14 03:41:33 +0000 |
commit | 7f0170c1975fe55c58f6f2a968e1fc2248732fbe (patch) | |
tree | fcc1c35b5f5d331f33390c9a2cc2fc8bc2b850ee /test | |
parent | daf27ea899fbd94a020cc6f4680279ea0ac65064 (diff) | |
download | external_llvm-7f0170c1975fe55c58f6f2a968e1fc2248732fbe.zip external_llvm-7f0170c1975fe55c58f6f2a968e1fc2248732fbe.tar.gz external_llvm-7f0170c1975fe55c58f6f2a968e1fc2248732fbe.tar.bz2 |
Don't attempt to add 'nsw' when intermediate instructions had no such guarantee.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137572 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Transforms/InstCombine/nsw.ll | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/test/Transforms/InstCombine/nsw.ll b/test/Transforms/InstCombine/nsw.ll index 6982963..0e71507 100644 --- a/test/Transforms/InstCombine/nsw.ll +++ b/test/Transforms/InstCombine/nsw.ll @@ -46,10 +46,38 @@ define i32 @preserve1(i32 %x) nounwind { ret i32 %add3 } +; CHECK: @preserve2 +; CHECK: add nsw i8 %A, %B +; CHECK: add nsw i8 +define i8 @preserve2(i8 %A, i8 %B) nounwind { + %x = add nsw i8 %A, 10 + %y = add nsw i8 %B, 10 + %add = add nsw i8 %x, %y + ret i8 %add +} + ; CHECK: @nopreserve1 ; CHECK: add i8 %x, -126 define i8 @nopreserve1(i8 %x) nounwind { %add = add nsw i8 %x, 127 %add3 = add nsw i8 %add, 3 ret i8 %add3 -}
\ No newline at end of file +} + +; CHECK: @nopreserve2 +; CHECK: add i8 %x, 3 +define i8 @nopreserve2(i8 %x) nounwind { + %add = add i8 %x, 1 + %add3 = add nsw i8 %add, 2 + ret i8 %add3 +} + +; CHECK: @nopreserve3 +; CHECK: add i8 %A, %B +; CHECK: add i8 +define i8 @nopreserve3(i8 %A, i8 %B) nounwind { + %x = add i8 %A, 10 + %y = add i8 %B, 10 + %add = add nsw i8 %x, %y + ret i8 %add +} |