forked from OSchip/llvm-project
50 lines
1.1 KiB
LLVM
50 lines
1.1 KiB
LLVM
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||
|
; RUN: opt %s -simplifycfg -instcombine -S | FileCheck %s
|
||
|
|
||
|
; TODO: ABS call should be optimized away
|
||
|
define i32 @assume1(i32 %p) {
|
||
|
; CHECK-LABEL: @assume1(
|
||
|
; CHECK-NEXT: entry:
|
||
|
; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i32 [[P:%.*]], 0
|
||
|
; CHECK-NEXT: [[NEG:%.*]] = sub nsw i32 0, [[P]]
|
||
|
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[TMP0]], i32 [[NEG]], i32 [[P]]
|
||
|
; CHECK-NEXT: ret i32 [[TMP1]]
|
||
|
;
|
||
|
entry:
|
||
|
%cmp = icmp sle i32 %p, 0
|
||
|
br i1 %cmp, label %if.then, label %if.end
|
||
|
|
||
|
if.then:
|
||
|
unreachable
|
||
|
|
||
|
if.end:
|
||
|
%call = call i32 @abs(i32 %p)
|
||
|
ret i32 %call
|
||
|
}
|
||
|
|
||
|
|
||
|
define i32 @assume2(i32 %p) {
|
||
|
; CHECK-LABEL: @assume2(
|
||
|
; CHECK-NEXT: entry:
|
||
|
; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i32 [[P:%.*]], 0
|
||
|
; CHECK-NEXT: [[NEG:%.*]] = sub nsw i32 0, [[P]]
|
||
|
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[TMP0]], i32 [[NEG]], i32 [[P]]
|
||
|
; CHECK-NEXT: ret i32 [[TMP1]]
|
||
|
;
|
||
|
entry:
|
||
|
%cmp = icmp sgt i32 %p, 0
|
||
|
br i1 %cmp, label %if.then, label %if.else
|
||
|
|
||
|
if.then:
|
||
|
br label %if.end
|
||
|
|
||
|
if.else:
|
||
|
unreachable
|
||
|
|
||
|
if.end:
|
||
|
%call = call i32 @abs(i32 %p)
|
||
|
ret i32 %call
|
||
|
}
|
||
|
|
||
|
declare i32 @abs(i32)
|