Skip to content

Commit

Permalink
[InstCombine] Added regression test to narrow-swich.ll
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293018 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Gerolf-Apple committed Jan 25, 2017
1 parent fe49b71 commit 6109735
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/Transforms/InstCombine/narrow-switch.ll
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,45 @@ case124:
ret i8 5
}

; Make sure the arithmetic evaluation of the switch
; condition is evaluated on the original type
define i32 @trunc32to16(i32 %a0) #0 {
; ALL-LABEL: @trunc32to16(
; ALL: switch i16
; ALL-NEXT: i16 63, label %sw.bb
; ALL-NEXT: i16 1, label %sw.bb1
; ALL-NEXT: i16 100, label %sw.bb2
; ALL-NEXT: ]
;
entry:
%retval = alloca i32, align 4
%xor = xor i32 %a0, 1034460917
%shr = lshr i32 %xor, 16
%add = add i32 %shr, -917677090
switch i32 %add, label %sw.epilog [
i32 -917677027, label %sw.bb
i32 -917677089, label %sw.bb1
i32 -917676990, label %sw.bb2
]

sw.bb: ; preds = %entry
store i32 90, i32* %retval, align 4
br label %return

sw.bb1: ; preds = %entry
store i32 91, i32* %retval, align 4
br label %return

sw.bb2: ; preds = %entry
store i32 92, i32* %retval, align 4
br label %return

sw.epilog: ; preds = %entry
store i32 113, i32* %retval, align 4
br label %return

return: ; preds = %sw.epilog, %sw.bb2,
%rval = load i32, i32* %retval, align 4
ret i32 %rval
}

0 comments on commit 6109735

Please sign in to comment.