Which triggers on valid, but not useful, IR such as a undef mask.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for the patch so quickly!
I really have no idea if the assert actually makes sense or not though, so it's best if @spatel can have an opinion.
Was the failure only a fuzzer problem?
Ideally, callers shouldn't be wasting their time on analysis of degenerate code, so that assert might have actually been useful for real code.
Also, if this did happen in real code, we probably don't want to claim that this shuffle uses a source value if the shuffle doesn't actually exist (see inline comment).
llvm/lib/IR/Instructions.cpp | ||
---|---|---|
2056 | I think it would be better to change to: // Allow for degenerate case: completely undef mask means neither source is used. return UsesLHS || UsesRHS; | |
llvm/test/CodeGen/X86/cgp_shuffle_crash.ll | ||
1 ↗ | (On Diff #270051) | I prefer a more direct test of CGP using "opt -codegenprepare -S". Also, the test can be reduced to a single block (not sure if this is minimal): define <2 x i8> @autogen_SD20565(i32 %x) { %Shuf = shufflevector <2 x i8> zeroinitializer, <2 x i8> zeroinitializer, <2 x i32> undef %Cmp = icmp slt i32 480483, %x %B = mul <2 x i8> %Shuf, %Shuf %S = select i1 %Cmp, <2 x i8> %B, <2 x i8> zeroinitializer ret <2 x i8> %Shuf } |
Was the failure only a fuzzer problem?
Not sure, but either it seems harsh to assert of technically legal IR.
Ideally, callers shouldn't be wasting their time on analysis of degenerate code, so that assert might have actually been useful for real code.
I'll have a look into the callsites to see if it's easier enough to skip on undef masks.
llvm/lib/IR/Instructions.cpp | ||
---|---|---|
2056 | Looks good. |
- Changed return value and added comment.
- Added a few internal UndefValue where possible.
- Moved test.
LGTM
llvm/lib/IR/Instructions.cpp | ||
---|---|---|
2056 | Formatting: 80-column. | |
llvm/test/Transforms/CodeGenPrepare/X86/cgp_shuffle_crash.ll | ||
14 | bugpoint tends to produce tests like this with undef/unused values, and then those tests wiggle or become worthless when unrelated improvements are made. For that reason, I still prefer my more-defined version of the test. :) |
llvm/test/Transforms/CodeGenPrepare/X86/cgp_shuffle_crash.ll | ||
---|---|---|
14 | Ah, sorry, will do. |
I think it would be better to change to: