1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/test/Transforms/InstCombine/ExtractCast.ll
Daan Sprenkels e4be55bce7 [InstCombine] Transform extelt-trunc -> bitcast-extelt
Canonicalize the case when a scalar extracted from a vector is
truncated.  Transform such cases to bitcast-then-extractelement.
This will enable erasing the truncate operation.

This commit fixes PR45314.

reviewers: spatel

Differential revision: https://reviews.llvm.org/D76983
2020-03-31 11:53:41 +02:00

26 lines
767 B
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S -o - | FileCheck %s
define i32 @a(<4 x i64> %I) {
; CHECK-LABEL: @a(
; CHECK-NEXT: [[TMP1:%.*]] = bitcast <4 x i64> [[I:%.*]] to <8 x i32>
; CHECK-NEXT: [[K:%.*]] = extractelement <8 x i32> [[TMP1]], i32 6
; CHECK-NEXT: ret i32 [[K]]
;
%J = trunc <4 x i64> %I to <4 x i32>
%K = extractelement <4 x i32> %J, i32 3
ret i32 %K
}
define i32 @b(<4 x float> %I) {
; CHECK-LABEL: @b(
; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x float> [[I:%.*]], i32 3
; CHECK-NEXT: [[K:%.*]] = fptosi float [[TMP1]] to i32
; CHECK-NEXT: ret i32 [[K]]
;
%J = fptosi <4 x float> %I to <4 x i32>
%K = extractelement <4 x i32> %J, i32 3
ret i32 %K
}