[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / llvm / test / Transforms / InstCombine / 2010-01-28-NegativeSRem.ll
blob077419027c1bf88b6fdaac3ee415c4583ef57998
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 ; PR6165
5 define i32 @f() {
6 ; CHECK-LABEL: @f(
7 ; CHECK-NEXT:  entry:
8 ; CHECK-NEXT:    br label [[BB1:%.*]]
9 ; CHECK:       BB1:
10 ; CHECK-NEXT:    [[X:%.*]] = phi i32 [ -29, [[ENTRY:%.*]] ], [ 0, [[BB1]] ]
11 ; CHECK-NEXT:    [[REM:%.*]] = srem i32 [[X]], 2
12 ; CHECK-NEXT:    [[T:%.*]] = icmp eq i32 [[REM]], -1
13 ; CHECK-NEXT:    br i1 [[T]], label [[BB2:%.*]], label [[BB1]]
14 ; CHECK:       BB2:
15 ; CHECK-NEXT:    ret i32 [[X]]
17 entry:
18   br label %BB1
20 BB1:                                              ; preds = %BB1, %entry
21   %x = phi i32 [ -29, %entry ], [ 0, %BB1 ]       ; <i32> [#uses=2]
22   %rem = srem i32 %x, 2                           ; <i32> [#uses=1]
23   %t = icmp eq i32 %rem, -1                       ; <i1> [#uses=1]
24   br i1 %t, label %BB2, label %BB1
26 BB2:                                              ; preds = %BB1
27   ret i32 %x