1 ; RUN: opt -S -passes=consthoist < %s | FileCheck %s
2 target datalayout = "E-m:e-i64:64-n32:64"
3 target triple = "powerpc64-unknown-linux-gnu"
5 ; Here the masks are all contiguous, and should not be hoisted.
6 define i32 @test1() nounwind {
9 ; CHECK-NOT: bitcast i32 65535 to i32
10 ; CHECK: and i32 undef, 65535
11 %conv121 = and i32 undef, 65535
12 br i1 undef, label %if.then152, label %if.end167
15 ; CHECK: and i32 undef, 65535
16 %conv153 = and i32 undef, 65535
17 br i1 undef, label %if.end167, label %end2
20 ; CHECK: and i32 {{.*}}, 32768
21 %shl161 = shl nuw nsw i32 %conv121, 15
22 %0 = load i8, ptr undef, align 1
23 %conv169 = zext i8 %0 to i32
24 %shl170 = shl nuw nsw i32 %conv169, 7
25 %shl161.masked = and i32 %shl161, 32768
26 %conv174 = or i32 %shl170, %shl161.masked
27 %cmp178 = icmp ugt i32 %conv174, 32767
28 br i1 %cmp178, label %end1, label %end2
37 ; Here the masks are not contiguous, and should be hoisted.
38 define i32 @test2() nounwind {
41 ; CHECK: bitcast i32 65531 to i32
42 %conv121 = and i32 undef, 65531
43 br i1 undef, label %if.then152, label %if.end167
46 %conv153 = and i32 undef, 65531
47 br i1 undef, label %if.end167, label %end2
50 ; CHECK: add i32 {{.*}}, -32758
51 %shl161 = shl nuw nsw i32 %conv121, 15
52 %0 = load i8, ptr undef, align 1
53 %conv169 = zext i8 %0 to i32
54 %shl170 = shl nuw nsw i32 %conv169, 7
55 %shl161.masked = and i32 %shl161, 32773
56 %conv174 = or i32 %shl170, %shl161.masked
57 %cmp178 = icmp ugt i32 %conv174, 32767
58 br i1 %cmp178, label %end1, label %end2