https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78037
Uroš Bizjak <ubizjak at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |NEW CC| |rguenth at gcc dot gnu.org Component|target |tree-optimization Assignee|ubizjak at gmail dot com |unassigned at gcc dot gnu.org --- Comment #10 from Uroš Bizjak <ubizjak at gmail dot com> --- Actually, the problem already starts with tree Early-VRP pass. Consider following testcase: int foo (int x) { return __builtin_ctz (x) & 0x1f; } And these definitions in i386.h: /* The value at zero is only defined for the BMI instructions LZCNT and TZCNT, not the BSR/BSF insns in the original isa. */ #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \ ((VALUE) = GET_MODE_BITSIZE (MODE), TARGET_BMI ? 1 : 0) #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \ ((VALUE) = GET_MODE_BITSIZE (MODE), TARGET_LZCNT ? 1 : 0) compile with gcc -O2 -mbmi, _.evrp dump shows: Value ranges after Early VRP: x.0_1: [0, +INF] _2: [0, 31] x_3(D): VARYING _4: [0, 31] foo (int x) { unsigned int x.0_1; int _2; int _4; <bb 2>: x.0_1 = (unsigned int) x_3(D); _2 = __builtin_ctz (x.0_1); _4 = _2; return _4; } It looks that VRP pass doesn't account for CTZ_DEFINED_VALUE_AT_ZERO and blindly assumes undefined value at zero. Unassign and recategorize PR as tree optimization problem.