• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -newgvn -S | FileCheck %s
3
4define i32 @main() {
5; CHECK-LABEL: @main(
6; CHECK-NEXT:  block1:
7; CHECK-NEXT:    br label [[BLOCK2:%.*]]
8; CHECK:       block2:
9; CHECK-NEXT:    ret i32 0
10;
11block1:
12  %z1 = bitcast i32 0 to i32
13  br label %block2
14block2:
15  %z2 = bitcast i32 0 to i32
16  ret i32 %z2
17}
18
19; Test that we simplify selects properly
20define i64 @simplifyselect(i64 %x, i64 %y, i1 %c1, i1 %c2, i1 %zzz) {
21; CHECK-LABEL: @simplifyselect(
22; CHECK-NEXT:    [[SHARED:%.*]] = add i64 [[X:%.*]], [[Y:%.*]]
23; CHECK-NEXT:    [[R1:%.*]] = select i1 [[C1:%.*]], i64 [[SHARED]], i64 [[X]]
24; CHECK-NEXT:    [[R2:%.*]] = select i1 [[C2:%.*]], i64 [[SHARED]], i64 [[Y]]
25; CHECK-NEXT:    [[R:%.*]] = add i64 [[R1]], [[R2]]
26; CHECK-NEXT:    ret i64 [[R]]
27;
28  %shared = add i64 %x, %y
29  %r1 = select i1 %c1, i64 %shared, i64 %x
30  %r2 = select i1 %c2, i64 %shared, i64 %y
31  %tmp = select i1 %c2, i64 %x, i64 0
32  %r2_eq2 = select i1 %zzz, i64 %r2, i64 %r2
33  %r = add i64 %r1, %r2_eq2
34  ret i64 %r
35}
36