1 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 define i32 @test1(i32 %X, i8 %A) {
5 %shift.upgrd.1 = zext i8 %A to i32 ; <i32> [#uses=1]
6 ; can be logical shift.
7 %Y = ashr i32 %X, %shift.upgrd.1 ; <i32> [#uses=1]
8 %Z = and i32 %Y, 1 ; <i32> [#uses=1]
10 ; CHECK-LABEL: @test1(
11 ; CHECK: lshr i32 %X, %shift.upgrd.1
14 define i32 @test2(i8 %tmp) {
15 %tmp3 = zext i8 %tmp to i32 ; <i32> [#uses=1]
16 %tmp4 = add i32 %tmp3, 7 ; <i32> [#uses=1]
17 %tmp5 = ashr i32 %tmp4, 3 ; <i32> [#uses=1]
19 ; CHECK-LABEL: @test2(
20 ; CHECK: lshr i32 %tmp4, 3
23 define i64 @test3(i1 %X, i64 %Y, i1 %Cond) {
24 br i1 %Cond, label %T, label %F
26 %X2 = sext i1 %X to i64
32 %P = phi i64 [%X2, %T], [%Y2, %F]
36 ; CHECK-LABEL: @test3(
38 ; CHECK-NEXT: ret i64 %P
41 define i64 @test4(i1 %X, i64 %Y, i1 %Cond) {
42 br i1 %Cond, label %T, label %F
44 %X2 = sext i1 %X to i64
50 %P = phi i64 [%X2, %T], [%Y2, %F]
55 ; CHECK-LABEL: @test4(
57 ; CHECK-NEXT: ret i64 %P
61 define i32 @test5(i32 %Y) {
62 br i1 undef, label %A, label %C
64 br i1 undef, label %B, label %D
68 br i1 undef, label %D, label %E
70 %P = phi i32 [0, %A], [0, %B], [%Y, %C]
73 ; CHECK-LABEL: @test5(
75 ; CHECK-NEXT: ashr i32 %P, 16