[llvm] [InstCombine] Simplify associative binary ops when there is a select between them (PR #172662)

Gábor Spaits via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 18 04:53:58 PST 2025


================
@@ -1234,10 +1208,11 @@ define i8 @udivSelectudivudivset1(i8 %arg0, i8 %arg1) {
 define i8 @udivSelectudivudivset2(i8 %arg0, i8 %arg1) {
 ; CHECK-LABEL: @udivSelectudivudivset2(
 ; CHECK-NEXT:    [[V0:%.*]] = icmp eq i8 [[ARG1:%.*]], -1
-; CHECK-NEXT:    [[V1:%.*]] = udiv i8 [[ARG0:%.*]], 13
-; CHECK-NEXT:    [[V2:%.*]] = select i1 [[V0]], i8 [[V1]], i8 [[ARG0]]
+; CHECK-NEXT:    [[TMP1:%.*]] = icmp ugt i8 [[V2:%.*]], -114
----------------
spaits wrote:

Maybe avoid this for `div`.

https://github.com/llvm/llvm-project/pull/172662


More information about the llvm-commits mailing list