At this time, there is a case where the indeterminate state (X state) of a RAM or the like spoils a result of the compaction in the MISR as described in the problems of BIST. An EOR gate is used at an entrance of the MISR, and an EOR gate is also used in a feedback loop of the MISR. If there is the indeterminate state of even one input to the EOR gate, an output of the EOR gate is brought into the