1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -instcombine -inline -S | FileCheck %s
3; PR3142
4
5define i32 @a(i32 %X) {
6; CHECK-LABEL: @a(
7; CHECK-NEXT:    [[T0:%.*]] = sub i32 0, [[X:%.*]]
8; CHECK-NEXT:    [[T1:%.*]] = sdiv i32 [[T0]], -3
9; CHECK-NEXT:    ret i32 [[T1]]
10;
11  %t0 = sub i32 0, %X
12  %t1 = sdiv i32 %t0, -3
13  ret i32 %t1
14}
15
16define i32 @b(i32 %X) {
17; CHECK-LABEL: @b(
18; CHECK-NEXT:    ret i32 715827882
19;
20  %t0 = call i32 @a(i32 -2147483648)
21  ret i32 %t0
22}
23
24define i32 @c(i32 %X) {
25; CHECK-LABEL: @c(
26; CHECK-NEXT:    ret i32 715827882
27;
28  %t0 = sub i32 0, -2147483648
29  %t1 = sdiv i32 %t0, -3
30  ret i32 %t1
31}
32