llvm-project
65201690 - [LVI] Raise MaxUsesToInspect limit in getValueAtUse to 6 (#241468)

Commit
3 days ago
[LVI] Raise MaxUsesToInspect limit in getValueAtUse to 6 (#241468) Using ternary operators can result in a redundant min() operation: ``` int need = avail < 0 ? -avail : 0; // -min(avail, 0) uint64_t add = avail < 0 ? (uint64_t)w << need : 0; // the min is redundant ``` The same can happen when using branches (see the referenced issue below). IR and the redundant min: ``` %5 = icmp slt i32 %4, 0 %6 = tail call i32 @llvm.smin.i32(i32 %4, i32 0) ; <== this can be eliminated %7 = sub nsw i32 0, %6 %8 = zext i32 %1 to i64 %9 = zext nneg i32 %7 to i64 %10 = shl i64 %8, %9 %11 = select i1 %5, i64 %10, i64 0 ``` This change increase a LVI limit to be able to eliminate the min() operation via CVP. See https://github.com/llvm/llvm-project/pull/240166. Fixes https://github.com/llvm/llvm-project/issues/239566. Assisted by: Claude
Author
Parents
Loading