aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/Transforms/CodeGenPrepare/X86/codegenprepare-hang-bitcast-phi.ll
blob: 7869d6182bd4abcfd379ddbe22aaa7d77de60b54 (plain)
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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
; RUN: opt -S -mtriple=x86_64-unknown-linux-gnu -passes="require<profile-summary>,function(codegenprepare)" < %s | FileCheck %s
; Check that CodeGenPrepare does not hang on this input.
; This was caused by an infinite loop between OptimizeNoopCopyExpression
; and optimizePhiType when handling same-type bitcasts.

define void @foo(ptr %p) {
; CHECK-LABEL: define void @foo(
; CHECK-SAME: ptr [[P:%.*]]) {
; CHECK-NEXT:  [[ENTRY:.*:]]
; CHECK-NEXT:    [[VAL:%.*]] = load i32, ptr [[P]], align 4
; CHECK-NEXT:    store i32 [[VAL]], ptr [[P]], align 4
; CHECK-NEXT:    ret void
;
entry:
  %val = load i32, ptr %p, align 4
  br i1 false, label %bb1, label %bb3

bb1:
  %c1 = bitcast i32 %val to i32
  br label %bb3

bb3:
  %phi = phi i32 [ %c1, %bb1 ], [ %val, %entry ]
  store i32 %phi, ptr %p, align 4
  ret void
}