[llvm] [InstCombine] Use sadd.sat for chained ldexp fold (PR #199274)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Tue May 26 17:00:19 PDT 2026
================
@@ -498,7 +549,10 @@ define float @ldexp_ldexp_opposite_constants(float %x) {
define float @ldexp_ldexp_negated_variable_reassoc(float %x, i32 %a) {
; CHECK-LABEL: define float @ldexp_ldexp_negated_variable_reassoc
; CHECK-SAME: (float [[X:%.*]], i32 [[A:%.*]]) {
-; CHECK-NEXT: ret float [[X]]
+; CHECK-NEXT: [[NEG_A:%.*]] = sub i32 0, [[A]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.sadd.sat.i32(i32 [[A]], i32 [[NEG_A]])
----------------
efriedma-quic wrote:
I guess the edge case here is a == INT_MIN: in that case, the saturated sum is INT_MIN.
https://github.com/llvm/llvm-project/pull/199274
More information about the llvm-commits
mailing list