- 
                Notifications
    
You must be signed in to change notification settings  - Fork 15.1k
 
Description
Problem
Hitting assertion:
llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:25712: llvm::SDValue narrowExtractedVectorBinOp(llvm::EVT, llvm::SDValue, unsigned int, const llvm::SDLoc &, llvm::SelectionDAG &, bool): Assertion `(Index % VT.getVectorNumElements()) == 0 && "Extract index is not a multiple of the vector length."' failed.When compiling the attached program.
To reproduce:
llc --march=amdgcn ./bug.txt
confirmed that at commit 5d115e49ba70 the problem still exists.
Initial triage
Initial triage posted here: iree-org/iree#21646 (comment)
Problem is that when doing dagcombine we hit this assertion: https://github.com/llvm/llvm-project/pull/138279/files#diff-d0eb75096db76ab253fc7f8ae6343c4b4516fc619d851898cbdac1a5bf481941R25186-L25197
The culprit is this node:
t544: v32f32 = fdiv # D:1 t541, t464
...
t557: v3f32 = extract_subvector # D:1 t544, Constant:i32<16>
where index
16cannot be divided by vector length3-- which is a hard requirement forextract_subvector: the index must be a multiple of the minimum number of elements in the result type. Should look for the reason whyv3f32is a legalized type at this stage.
Simple problem analysis
The input program is trying to do reduction of a vector using @llvm.vector.reduce.fadd.v3f32 in a loop. The loop is unrolled. And then type legalizer turns the residual extraction:
t370: v51f32 = fdiv # D:1 t369, t12 // both operands are of type v51f32
...
t431: v3f32 = extract_subvector # D:1 t370, Constant:i32<48>
into:
t544: v32f32 = fdiv # D:1 t541, t464 // both operands are of type v32f32
...
t557: v3f32 = extract_subvector # D:1 t544, Constant:i32<16>
without checking if it is possible to form a valid extract_subvector.