Skip to content

Commit 5056369

Browse files
committed
[GISel] Teach computeKnownBitsImpl to handle COPY instructions that change bit width.
The selectShiftMask ComplexRenderFn on RISCV calls computeKnownBits. I encountered a case where we looked through a G_PHI and found a COPY that was created from an already selected G_ANYEXT from s32 to s64. s32 and s64 integers on RISC-V end up in the same register class.a The input to the COPY was an already selected s32 SELECT instruction. We need an s32 SELECT to be legal to support f32 selects. If it isn't used by FP operations, regbank select will assign to GPR. This patch uses KnownBits::anyextOrTrunc to adjust the width when they mismatch. I haven't reduced a test case yet, but wanted to make sure this is the right fix.
1 parent 983f88c commit 5056369

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ void GISelKnownBits::computeKnownBitsImpl(Register R, KnownBits &Known,
253253
// For COPYs we don't do anything, don't increase the depth.
254254
computeKnownBitsImpl(SrcReg, Known2, DemandedElts,
255255
Depth + (Opcode != TargetOpcode::COPY));
256+
Known2 = Known2.anyextOrTrunc(BitWidth);
256257
Known = Known.intersectWith(Known2);
257258
// If we reach a point where we don't know anything
258259
// just stop looking through the operands.

0 commit comments

Comments
 (0)