File: load-extractelement-scalarization.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (38 lines) | stat: -rw-r--r-- 1,809 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse2 | FileCheck %s
; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx2 | FileCheck %s

; infinite loop if we add the erased instructions to the work list in the wrong order.
define void @multiple_extract(ptr %p) {
; CHECK-LABEL: @multiple_extract(
; CHECK-NEXT:    [[VP:%.*]] = load ptr, ptr [[P:%.*]], align 8
; CHECK-NEXT:    [[TMP1:%.*]] = getelementptr inbounds <2 x i32>, ptr [[VP]], i32 0, i64 0
; CHECK-NEXT:    [[E0:%.*]] = load i32, ptr [[TMP1]], align 16
; CHECK-NEXT:    [[TMP2:%.*]] = getelementptr inbounds <2 x i32>, ptr [[VP]], i32 0, i64 1
; CHECK-NEXT:    [[E1:%.*]] = load i32, ptr [[TMP2]], align 4
; CHECK-NEXT:    store i32 [[E0]], ptr [[P]], align 4
; CHECK-NEXT:    [[P1:%.*]] = getelementptr inbounds nuw i8, ptr [[P]], i64 4
; CHECK-NEXT:    store i32 [[E1]], ptr [[P1]], align 4
; CHECK-NEXT:    ret void
;
  %vp = load ptr, ptr %p, align 8
  %v = load <2 x i32>, ptr %vp, align 16
  %e0 = extractelement <2 x i32> %v, i64 0
  %e1 = extractelement <2 x i32> %v, i64 1
  store i32 %e0, ptr %p, align 4
  %p1 = getelementptr inbounds nuw i8, ptr %p, i64 4
  store i32 %e1, ptr %p1, align 4
  ret void
}

; infinite loop if we fold an extract that is waiting to be erased
define void @unused_extract(ptr %p) {
; CHECK-LABEL: @unused_extract(
; CHECK-NEXT:    ret void
;
  %load = load <4 x float>, ptr %p, align 8
  %shuffle0 = shufflevector <4 x float> zeroinitializer, <4 x float> %load, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
  %shuffle1 = shufflevector <4 x float> %shuffle0, <4 x float> zeroinitializer, <4 x i32> <i32 0, i32 4, i32 poison, i32 poison>
  %extract = extractelement <4 x float> %load, i64 1
  ret void
}