File: pr63763.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (52 lines) | stat: -rw-r--r-- 1,960 bytes parent folder | download | duplicates (6)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
; RUN: opt -S -passes='print<scalar-evolution>,indvars' < %s 2>/dev/null | FileCheck %s

; We should use %invariant.op.us rather than %invariant.op for the exit
; value expansion. They have the same SCEV, but %invariant.op is more
; poisonous.
define i32 @test(i1 %c) {
; CHECK-LABEL: define i32 @test
; CHECK-SAME: (i1 [[C:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[SEL:%.*]] = select i1 [[C]], i32 33, i32 0
; CHECK-NEXT:    [[SUB_I:%.*]] = add nsw i32 [[SEL]], -68
; CHECK-NEXT:    [[SHL_I:%.*]] = shl nuw nsw i32 1, [[SUB_I]]
; CHECK-NEXT:    [[ADD:%.*]] = add nsw i32 [[SHL_I]], [[SEL]]
; CHECK-NEXT:    [[SEXT:%.*]] = shl i32 [[ADD]], 24
; CHECK-NEXT:    [[CONV2:%.*]] = ashr exact i32 [[SEXT]], 24
; CHECK-NEXT:    [[INVARIANT_OP:%.*]] = sub nsw i32 7, [[CONV2]]
; CHECK-NEXT:    call void @use(i32 [[INVARIANT_OP]])
; CHECK-NEXT:    [[SEXT_US:%.*]] = shl i32 [[SEL]], 24
; CHECK-NEXT:    [[CONV2_US:%.*]] = ashr exact i32 [[SEXT_US]], 24
; CHECK-NEXT:    br label [[LOOP:%.*]]
; CHECK:       loop:
; CHECK-NEXT:    br i1 true, label [[EXIT:%.*]], label [[LOOP]]
; CHECK:       exit:
; CHECK-NEXT:    [[INVARIANT_OP_US:%.*]] = sub nsw i32 7, [[CONV2_US]]
; CHECK-NEXT:    ret i32 [[INVARIANT_OP_US]]
;
entry:
  %sel = select i1 %c, i32 33, i32 0
  %sub.i = add nsw i32 %sel, -68
  %shl.i = shl nuw nsw i32 1, %sub.i
  %add = add nsw i32 %shl.i, %sel
  %sext = shl i32 %add, 24
  %conv2 = ashr exact i32 %sext, 24
  %invariant.op = sub nsw i32 7, %conv2
  call void @use(i32 %invariant.op)
  %sext.us = shl i32 %sel, 24
  %conv2.us = ashr exact i32 %sext.us, 24
  %invariant.op.us = sub nsw i32 7, %conv2.us
  br label %loop

loop:
  %iv = phi i32 [ %iv.next , %loop ], [ 0, %entry ]
  %iv.next = add i32 %iv, 1
  %cmp = icmp eq i32 %iv.next, %invariant.op.us
  br i1 %cmp, label %exit, label %loop

exit:
  ret i32 %iv.next
}

declare void @use(i32)