[PATCH] D67280: [Mips][msa] Fix inifinite loop for mips.nori.b intrinsic
Mirko Brkusanin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 08:39:34 PDT 2019
mbrkusanin added a comment.
More detailed explanation follows:
Expansion for mips.nori.b goes something like this:
mips.nori.b %dst, %val, imm
%dst = not (or %value, imm)
%dst = xor (or %value, imm), -1
For -1 as immediate we should get:
%dst = xor (or %value, -1), -1
%dst = xor -1, -1
%dst = 0
When value of immediate is 255 (-1 for i8, so all bits are 1) issue shows up in DAGCombiner when it runs into node for XOR:
SelectionDAG:
...
t31: v2i64 = BUILD_VECTOR Constant:i64<0>, Constant:i64<0>
t2: i64,ch = CopyFromReg t0, Register:i64 %0
t28: v2i64 = insert_vector_elt t31, t2, Constant:i32<0>
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t30: v2i64 = insert_vector_elt t28, t4, Constant:i32<1>
t6: v16i8 = bitcast t30
t24: v16i8 = or t6, t23
t25: v16i8 = xor t24, t23
...
t23: v16i8 = BUILD_VECTOR Constant:i32<255>, Constant:i32<255>, ...
-DAGCombiner::visitXOR() is called which in turns calles SimplifyDemandedBits().
--SimplifyDemandedBits() for XOR will call SimplifyDemandedBits() for OR.
--SimplifyDemandedBits() for OR will call SimplifyDemandedBits() for Operand(0)
--SimplifyDemandedBits() for Operand(0) will make a new UNDEF node.
-Legalizer for Mips will replace UNDEF node with a new Constant<0> node.
-DAGCombiner::visitXOR() is called which again makes a new UNDEF node (this time from Constant<0>).
Legalizer for Mips will replace UNDEF node with a new Constant<0> node.
...
now we are in a loop.
Making UNDEF legal avoids making a loop. It also produces shorter code which is why there are changes to other tests.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67280/new/
https://reviews.llvm.org/D67280
More information about the llvm-commits
mailing list