File: constexpr-to-instr-dups.ll

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,245,064 kB
  • sloc: cpp: 7,619,731; 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,676; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (30 lines) | stat: -rw-r--r-- 843 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
; RUN: opt -expand-constant-exprs %s.bc -S | FileCheck %s
@foo = external constant i32

define i32 @test(i32 %arg) {
entry:
  switch i32 %arg, label %cont [
    i32 1, label %cont
    i32 2, label %nonconst
  ]

nonconst:
  %cmp = icmp ne i32 %arg, 2
  br i1 %cmp, label %cont, label %cont

; CHECK-LABEL: phi.constexpr:
; CHECK-NEXT:    %constexpr = ptrtoint ptr @foo to i32
; CHECK-NEXT:    %constexpr1 = or i32 %constexpr, 5
; CHECK-NEXT:    br label %cont


; CHECK-LABEL: cont:
; CHECK-NEXT:    %res = phi i32 [ %constexpr1, %phi.constexpr ], [ 1, %nonconst ], [ 1, %nonconst ]
; CHECK-NEXT:    ret i32 %res
cont:
  %res = phi i32 [or (i32 5, i32 ptrtoint (ptr @foo to i32)), %entry],
                 [or (i32 5, i32 ptrtoint (ptr @foo to i32)), %entry],
                 [1, %nonconst],
                 [1, %nonconst]
  ret i32 %res
}