llvm-project/llvm/test/Transforms/InstCombine/2010-01-28-NegativeSRem.ll

29 lines
958 B
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
; PR6165
define i32 @f() {
; CHECK-LABEL: @f(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[BB1:%.*]]
; CHECK: BB1:
; CHECK-NEXT: [[X:%.*]] = phi i32 [ -29, [[ENTRY:%.*]] ], [ 0, [[BB1]] ]
; CHECK-NEXT: [[REM:%.*]] = srem i32 [[X]], 2
; CHECK-NEXT: [[T:%.*]] = icmp eq i32 [[REM]], -1
; CHECK-NEXT: br i1 [[T]], label [[BB2:%.*]], label [[BB1]]
; CHECK: BB2:
; CHECK-NEXT: ret i32 [[X]]
;
entry:
br label %BB1
BB1: ; preds = %BB1, %entry
%x = phi i32 [ -29, %entry ], [ 0, %BB1 ] ; <i32> [#uses=2]
%rem = srem i32 %x, 2 ; <i32> [#uses=1]
%t = icmp eq i32 %rem, -1 ; <i1> [#uses=1]
br i1 %t, label %BB2, label %BB1
BB2: ; preds = %BB1
ret i32 %x
}