diff options
Diffstat (limited to 'test/Transforms/Reassociate/canonicalize-neg-const.ll')
-rw-r--r-- | test/Transforms/Reassociate/canonicalize-neg-const.ll | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/test/Transforms/Reassociate/canonicalize-neg-const.ll b/test/Transforms/Reassociate/canonicalize-neg-const.ll index e85a963..465460c 100644 --- a/test/Transforms/Reassociate/canonicalize-neg-const.ll +++ b/test/Transforms/Reassociate/canonicalize-neg-const.ll @@ -49,18 +49,6 @@ define double @test3(double %x, double %y) { ret double %mul3 } -; Canonicalize (x - -1234 * y) -define i64 @test4(i64 %x, i64 %y) { -; CHECK-LABEL: @test4 -; CHECK-NEXT: mul i64 %y, 1234 -; CHECK-NEXT: add i64 %mul, %x -; CHECK-NEXT: ret i64 %sub - - %mul = mul i64 %y, -1234 - %sub = sub i64 %x, %mul - ret i64 %sub -} - ; Canonicalize (x - -0.1234 * y) define double @test5(double %x, double %y) { ; CHECK-LABEL: @test5 @@ -156,3 +144,13 @@ define double @test12(double %x, double %y) { %add = fadd double %div, %x ret double %add } + +; Don't create an NSW violation +define i4 @test13(i4 %x) { +; CHECK-LABEL: @test13 +; CHECK-NEXT: %[[mul:.*]] = mul nsw i4 %x, -2 +; CHECK-NEXT: %[[add:.*]] = add i4 %[[mul]], 3 + %mul = mul nsw i4 %x, -2 + %add = add i4 %mul, 3 + ret i4 %add +} |