Add a testcase where there is an overflow when combining two constants.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 5 Jun 2014 21:29:49 +0000 (21:29 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 5 Jun 2014 21:29:49 +0000 (21:29 +0000)
I noticed that a proposed optimization would have prevented this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210287 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/add2.ll

index 67d560e500a52de1f2d84de6a28102032474cdf5..aaf3a7a235bf8e9cdde260b709a8a3afc8a8c34c 100644 (file)
@@ -76,3 +76,13 @@ define <2 x i64> @test8(<2 x i64> %A) {
 ; CHECK-NEXT: %add = sub <2 x i64> <i64 1, i64 2>, %A
 ; CHECK-NEXT: ret <2 x i64> %add
 }
+
+define i16 @test9(i16 %a) {
+       %b = mul i16 %a, 2
+       %c = mul i16 %a, 32767
+       %d = add i16 %b, %c
+       ret i16 %d
+; CHECK-LABEL: @test9(
+; CHECK-NEXT:  %d = mul i16 %a, -32767
+; CHECK-NEXT:  ret i16 %d
+}