[PATCH] D107966: [SLP]Do not emit extract elements for insertelements users, replace with shuffles directly.
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 24 03:51:41 PDT 2022
ABataev added a comment.
In D107966#3533620 <https://reviews.llvm.org/D107966#3533620>, @fhahn wrote:
> Unfortunately the latest version is still causing crashes when build SPEC2017 on X86. Reproducer below:
>
> target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
> target triple = "x86_64-apple-macosx"
>
> %struct.hoge = type { [7 x i32 (i8*, i32, i8*, i32)*], [7 x i32 (i8*, i32, i8*, i32)*], [7 x i32 (i8*, i32, i8*, i32)*], [7 x i32 (i8*, i32, i8*, i32)*], [4 x i32 (i8*, i32, i8*, i32)*], [7 x i32 (i8*, i32, i8*, i32)*], [7 x i32 (i8*, i32, i8*, i32)*], [7 x i32 (i8*, i32, i8*, i32)*], [7 x void (i8*, i8*, i8*, i8*, i32, i32*)*], [7 x void (i8*, i8*, i8*, i8*, i8*, i32, i32*)*], [7 x i32 (i8*, i32, i8*, i32)*], i32 (i8*, i32, i8*, i32, i32*)*, [4 x i64 (i8*, i32)*], [4 x i64 (i8*, i32)*], void (i8*, i32, i8*, i32, [4 x i32]*)*, float ([4 x i32]*, [4 x i32]*, i32)*, [7 x void (i8*, i8*, i8*, i8*, i32, i32*)*], [7 x void (i8*, i8*, i8*, i8*, i8*, i32, i32*)*], [7 x void (i8*, i8*, i8*, i8*, i32, i32*)*], [7 x void (i8*, i8*, i8*, i8*, i8*, i32, i32*)*], [7 x i32 (i32*, i16*, i32, i16*, i16*, i32, i32)*], void (i8*, i8*, i32*)*, void (i8*, i8*, i32*)*, void (i8*, i8*, i32*)*, void (i8*, i8*, i32*)*, void (i8*, i8*, i32*)*, void (i8*, i8*, i32*)*, void (i8*, i8*, i32*)*, void (i8*, i8*, i32*)*, void (i8*, i8*, i32*)*, void (i8*, i8*, i32*)*, void (i8*, i8*, i32*)*, void (i8*, i8*, i32*)* }
>
> define i64 @quux.51(i8* %arg, i32 %arg1) unnamed_addr #0 {
> bb:
> %tmp = add i32 undef, undef
> %tmp2 = sub i32 undef, undef
> %tmp3 = add i32 undef, undef
> %tmp4 = sub i32 undef, undef
> %tmp5 = add nsw i32 %tmp3, %tmp
> %tmp6 = sub nsw i32 %tmp, %tmp3
> %tmp7 = add nsw i32 %tmp4, %tmp2
> %tmp8 = sub nsw i32 %tmp2, %tmp4
> %tmp9 = add i32 undef, %tmp5
> %tmp10 = xor i32 %tmp9, undef
> %tmp11 = add i32 undef, %tmp7
> %tmp12 = xor i32 %tmp11, undef
> %tmp13 = add i32 undef, %tmp6
> %tmp14 = xor i32 %tmp13, undef
> %tmp15 = add i32 undef, %tmp8
> %tmp16 = xor i32 %tmp15, undef
> %tmp17 = add i32 %tmp12, %tmp10
> %tmp18 = add i32 %tmp17, %tmp14
> %tmp19 = add i32 %tmp18, %tmp16
> %tmp20 = add i32 undef, undef
> %tmp21 = sub i32 undef, undef
> %tmp22 = add i32 undef, undef
> %tmp23 = sub i32 undef, undef
> %tmp24 = add nsw i32 %tmp22, %tmp20
> %tmp25 = sub nsw i32 %tmp20, %tmp22
> %tmp26 = add nsw i32 %tmp23, %tmp21
> %tmp27 = sub nsw i32 %tmp21, %tmp23
> %tmp28 = add i32 undef, %tmp24
> %tmp29 = xor i32 %tmp28, undef
> %tmp30 = add i32 undef, %tmp26
> %tmp31 = xor i32 %tmp30, undef
> %tmp32 = add i32 0, %tmp25
> %tmp33 = xor i32 %tmp32, 0
> %tmp34 = add i32 undef, %tmp27
> %tmp35 = xor i32 %tmp34, undef
> %tmp36 = add i32 %tmp31, %tmp19
> %tmp37 = add i32 %tmp36, %tmp29
> %tmp38 = add i32 %tmp37, %tmp33
> %tmp39 = add i32 %tmp38, %tmp35
> %tmp40 = add i32 undef, undef
> %tmp41 = sub i32 undef, undef
> %tmp42 = add i32 undef, undef
> %tmp43 = sub i32 undef, undef
> %tmp44 = add nsw i32 %tmp42, %tmp40
> %tmp45 = sub nsw i32 %tmp40, %tmp42
> %tmp46 = add nsw i32 %tmp43, %tmp41
> %tmp47 = sub nsw i32 %tmp41, %tmp43
> %tmp48 = add i32 undef, %tmp44
> %tmp49 = xor i32 %tmp48, undef
> %tmp50 = add i32 undef, %tmp46
> %tmp51 = xor i32 %tmp50, undef
> %tmp52 = add i32 undef, %tmp45
> %tmp53 = xor i32 %tmp52, undef
> %tmp54 = add i32 undef, %tmp47
> %tmp55 = xor i32 %tmp54, undef
> %tmp56 = add i32 %tmp51, %tmp39
> %tmp57 = add i32 %tmp56, %tmp49
> %tmp58 = add i32 %tmp57, %tmp53
> %tmp59 = add i32 %tmp58, %tmp55
> %tmp60 = load i32, i32* undef, align 4
> %tmp61 = add i32 undef, %tmp60
> %tmp62 = sub i32 %tmp60, undef
> %tmp63 = add i32 undef, undef
> %tmp64 = sub i32 undef, undef
> %tmp65 = add nsw i32 %tmp63, %tmp61
> %tmp66 = sub nsw i32 %tmp61, %tmp63
> %tmp67 = add nsw i32 %tmp64, %tmp62
> %tmp68 = sub nsw i32 %tmp62, %tmp64
> %tmp69 = add i32 undef, %tmp65
> %tmp70 = xor i32 %tmp69, undef
> %tmp71 = add i32 undef, %tmp67
> %tmp72 = xor i32 %tmp71, undef
> %tmp73 = add i32 undef, %tmp66
> %tmp74 = xor i32 %tmp73, undef
> %tmp75 = add i32 undef, %tmp68
> %tmp76 = xor i32 %tmp75, undef
> %tmp77 = add i32 %tmp72, %tmp59
> %tmp78 = add i32 %tmp77, %tmp70
> %tmp79 = add i32 %tmp78, %tmp74
> %tmp80 = add i32 %tmp79, %tmp76
> %tmp81 = add i32 undef, undef
> %tmp82 = sub i32 undef, undef
> %tmp83 = add i32 undef, undef
> %tmp84 = sub i32 undef, undef
> %tmp85 = add nsw i32 %tmp83, %tmp81
> %tmp86 = sub nsw i32 %tmp81, %tmp83
> %tmp87 = add nsw i32 %tmp84, %tmp82
> %tmp88 = sub nsw i32 %tmp82, %tmp84
> %tmp89 = add i32 undef, %tmp85
> %tmp90 = xor i32 %tmp89, undef
> %tmp91 = add i32 undef, %tmp87
> %tmp92 = xor i32 %tmp91, undef
> %tmp93 = add i32 undef, %tmp86
> %tmp94 = xor i32 %tmp93, undef
> %tmp95 = add i32 undef, %tmp88
> %tmp96 = xor i32 %tmp95, undef
> %tmp97 = add i32 %tmp92, %tmp80
> %tmp98 = add i32 %tmp97, %tmp90
> %tmp99 = add i32 %tmp98, %tmp94
> %tmp100 = add i32 %tmp99, %tmp96
> %tmp101 = add i32 undef, undef
> %tmp102 = sub i32 undef, undef
> %tmp103 = add i32 undef, undef
> %tmp104 = sub i32 undef, undef
> %tmp105 = add nsw i32 %tmp103, %tmp101
> %tmp106 = sub nsw i32 %tmp101, %tmp103
> %tmp107 = add nsw i32 %tmp104, %tmp102
> %tmp108 = sub nsw i32 %tmp102, %tmp104
> %tmp109 = add i32 undef, %tmp105
> %tmp110 = xor i32 %tmp109, undef
> %tmp111 = add i32 undef, %tmp107
> %tmp112 = xor i32 %tmp111, undef
> %tmp113 = add i32 undef, %tmp106
> %tmp114 = xor i32 %tmp113, undef
> %tmp115 = add i32 undef, %tmp108
> %tmp116 = xor i32 %tmp115, undef
> %tmp117 = add i32 %tmp112, %tmp100
> %tmp118 = add i32 %tmp117, %tmp110
> %tmp119 = add i32 %tmp118, %tmp114
> %tmp120 = add i32 %tmp119, %tmp116
> %tmp121 = add i32 undef, undef
> %tmp122 = sub i32 undef, undef
> %tmp123 = add i32 undef, undef
> %tmp124 = sub i32 undef, undef
> %tmp125 = add nsw i32 %tmp123, %tmp121
> %tmp126 = sub nsw i32 %tmp121, %tmp123
> %tmp127 = add nsw i32 %tmp124, %tmp122
> %tmp128 = sub nsw i32 %tmp122, %tmp124
> %tmp129 = add i32 undef, %tmp125
> %tmp130 = xor i32 %tmp129, undef
> %tmp131 = add i32 undef, %tmp127
> %tmp132 = xor i32 %tmp131, undef
> %tmp133 = add i32 undef, %tmp126
> %tmp134 = xor i32 %tmp133, undef
> %tmp135 = add i32 undef, %tmp128
> %tmp136 = xor i32 %tmp135, undef
> %tmp137 = add i32 %tmp132, %tmp120
> %tmp138 = add i32 %tmp137, %tmp130
> %tmp139 = add i32 %tmp138, %tmp134
> %tmp140 = add i32 %tmp139, %tmp136
> %tmp141 = add i32 undef, undef
> %tmp142 = sub i32 undef, undef
> %tmp143 = add i32 undef, undef
> %tmp144 = sub i32 undef, undef
> %tmp145 = add nsw i32 %tmp143, %tmp141
> %tmp146 = sub nsw i32 %tmp141, %tmp143
> %tmp147 = add nsw i32 %tmp144, %tmp142
> %tmp148 = sub nsw i32 %tmp142, %tmp144
> %tmp149 = add i32 undef, %tmp145
> %tmp150 = xor i32 %tmp149, undef
> %tmp151 = add i32 undef, %tmp147
> %tmp152 = xor i32 %tmp151, undef
> %tmp153 = add i32 undef, %tmp146
> %tmp154 = xor i32 %tmp153, undef
> %tmp155 = add i32 undef, %tmp148
> %tmp156 = xor i32 %tmp155, undef
> %tmp157 = add i32 %tmp152, %tmp140
> %tmp158 = add i32 %tmp157, %tmp150
> %tmp159 = add i32 %tmp158, %tmp154
> %tmp160 = add i32 %tmp159, %tmp156
> %tmp161 = and i32 %tmp160, 65535
> %tmp162 = add nuw nsw i32 %tmp161, undef
> %tmp163 = sub nsw i32 %tmp162, undef
> %tmp164 = zext i32 %tmp163 to i64
> %tmp165 = shl nuw i64 %tmp164, 32
> %tmp166 = add i64 %tmp165, undef
> ret i64 %tmp166
> }
>
> attributes #0 = { "target-features"="+64bit,+adx,+aes,+avx,+avx2" }
Ho Florian, tried to reproduce, was unable to do it:
opt -slp-vectorizer -S ./repro1.ll
; ModuleID = './repro1.ll'
source_filename = "./repro1.ll"
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx"
define i64 @quux.51(i8* %arg, i32 %arg1) unnamed_addr #0 {
bb:
%tmp60 = load i32, i32* undef, align 4
%0 = insertelement <32 x i32> poison, i32 %tmp60, i32 0
%shuffle = shufflevector <32 x i32> %0, <32 x i32> poison, <32 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 0, i32 0, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
%1 = add <32 x i32> %shuffle, poison
%2 = sub <32 x i32> %shuffle, poison
%3 = shufflevector <32 x i32> %1, <32 x i32> %2, <32 x i32> <i32 0, i32 33, i32 2, i32 35, i32 36, i32 5, i32 6, i32 39, i32 40, i32 9, i32 10, i32 43, i32 44, i32 13, i32 14, i32 47, i32 48, i32 17, i32 18, i32 51, i32 52, i32 21, i32 22, i32 55, i32 56, i32 25, i32 26, i32 59, i32 60, i32 29, i32 30, i32 63>
%4 = shufflevector <32 x i32> %3, <32 x i32> poison, <32 x i32> <i32 2, i32 3, i32 0, i32 1, i32 7, i32 6, i32 5, i32 4, i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12, i32 19, i32 18, i32 17, i32 16, i32 23, i32 22, i32 21, i32 20, i32 27, i32 26, i32 25, i32 24, i32 31, i32 30, i32 29, i32 28>
%5 = add nsw <32 x i32> %3, %4
%6 = sub nsw <32 x i32> %3, %4
%7 = shufflevector <32 x i32> %5, <32 x i32> %6, <32 x i32> <i32 0, i32 1, i32 34, i32 35, i32 4, i32 5, i32 38, i32 39, i32 8, i32 9, i32 42, i32 43, i32 12, i32 13, i32 46, i32 47, i32 16, i32 17, i32 50, i32 51, i32 20, i32 21, i32 54, i32 55, i32 24, i32 25, i32 58, i32 59, i32 28, i32 29, i32 62, i32 63>
%8 = add <32 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 0, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>, %7
%9 = xor <32 x i32> %8, <i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 0, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
%10 = call i32 @llvm.vector.reduce.add.v32i32(<32 x i32> %9)
%tmp161 = and i32 %10, 65535
%tmp162 = add nuw nsw i32 %tmp161, undef
%tmp163 = sub nsw i32 %tmp162, undef
%tmp164 = zext i32 %tmp163 to i64
%tmp165 = shl nuw i64 %tmp164, 32
%tmp166 = add i64 %tmp165, undef
ret i64 %tmp166
}
; Function Attrs: nocallback nofree nosync nounwind readnone willreturn
declare i32 @llvm.vector.reduce.add.v32i32(<32 x i32>) #1
attributes #0 = { "target-features"="+64bit,+adx,+aes,+avx,+avx2" }
attributes #1 = { nocallback nofree nosync nounwind readnone willreturn }
Could you check one more time, please?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107966/new/
https://reviews.llvm.org/D107966
More information about the llvm-commits
mailing list