File: pr137582.ll

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,245,028 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,675; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (34 lines) | stat: -rw-r--r-- 1,177 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes=correlated-propagation -S | FileCheck %s

; Make sure that the optimization does not introduce immediate UB.

define i8 @test(i16 %x) {
; CHECK-LABEL: define range(i8 -128, 1) i8 @test(
; CHECK-SAME: i16 [[X:%.*]]) {
; CHECK-NEXT:  [[ENTRY:.*]]:
; CHECK-NEXT:    [[OR:%.*]] = or i16 [[X]], 1
; CHECK-NEXT:    [[CONV:%.*]] = trunc i16 [[OR]] to i8
; CHECK-NEXT:    [[MIN:%.*]] = call noundef i8 @llvm.smin.i8(i8 [[CONV]], i8 0)
; CHECK-NEXT:    [[COND:%.*]] = icmp eq i16 [[X]], 0
; CHECK-NEXT:    br i1 [[COND]], label %[[IF_END:.*]], label %[[IF_THEN:.*]]
; CHECK:       [[IF_THEN]]:
; CHECK-NEXT:    br label %[[IF_END]]
; CHECK:       [[IF_END]]:
; CHECK-NEXT:    [[RES:%.*]] = phi i8 [ [[MIN]], %[[ENTRY]] ], [ 0, %[[IF_THEN]] ]
; CHECK-NEXT:    ret i8 [[RES]]
;
entry:
  %or = or i16 %x, 1
  %conv = trunc i16 %or to i8
  %min = call noundef i8 @llvm.smin.i8(i8 %conv, i8 0)
  %cond = icmp eq i16 %x, 0
  br i1 %cond, label %if.end, label %if.then

if.then:
  br label %if.end

if.end:
  %res = phi i8 [ %min, %entry ], [ 0, %if.then ]
  ret i8 %res
}