This prevents them from being assumed legal by the cost model.
This matches what is done for AArch64 SVE.
craig.topper on Apr 14 2022, 8:53 AM.Authored by
I agree they should probably be invalid, conceptually, but in reality I don't like that we have users of cost models crash when encountering invalid costs, with the rationale that the IR shouldn't contain anything with an invalid cost. I don't see how those two models are compatible.
To be honest, I don't have a good idea about the broader community view on invalid costs so I can't say for sure. I'm sure I've seen it argued in a review that invalid costs are a symptom of invalid IR which should have been legalized before reaching whichever part of code crashed. I can't find where I thought I saw that, though. I might have dreamed it.
CodeMetrics is one that definitely hard-crashes on invalid costs, and that's used by several optimizations that form the standard pipeline.
It's doubly hard for scalable-vector targets because many of the base TTIs assume fixed-length vectors and I've seen it argued in D119529 (maybe where @liaolucy is coming from) that that's acceptable. We can't assume anything other than invalid costs for scalable vectors in base TTI functions. But then, in my opinion, forcing targets to fully cost everything before things stop crashing is asking too much.
On reflection, it's the combination of these two issues that's making life hard. We have to fully cost everything scalable but we also can't return invalid costs to get there without making assumptions.
Thank Craig , I get the crash today.
This patch fix tsvc s451 crash.
fatal error: error in backend: Cannot select: t12: nxv2f32 = fsin nnan ninf nsz arcp contract afn reassoc t7 t7: nxv2f32,ch = load<(load unknown-size from %ir.uglygep51, align 16, !tbaa !4)> t0, t4, undef:i64 t4: i64 = add t3, t81 t3: i64,ch = CopyFromReg t0, Register:i64 %12 t2: i64 = Register %12 t81: i64 = ADDI t80, TargetGlobalAddress:i64<ptr @b> 0 [TF=3] t80: i64 = LUI TargetGlobalAddress:i64<ptr @b> 0 [TF=4] t78: i64 = TargetGlobalAddress<ptr @b> 0 [TF=4] t79: i64 = TargetGlobalAddress<ptr @b> 0 [TF=3] t6: i64 = undef In function: s451
For context, I've been landing patches to remove the "crash on invalid cost" issue that got discussed earlier in this review. As of now, there are no cases that I'm aware of where an invalid cost can lead to a crash. We'll probably find a couple more as time goes by, but the major changes are in, and these are just bugs we should fix.