[llvm] [ValueTracking] Propagate sign information out of loop (PR #175590)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 16 12:31:13 PST 2026


================
@@ -0,0 +1,45 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt < %s -passes=aggressive-instcombine -S | FileCheck %s
+target triple = "x86_64-unknown-linux-gnu"
+define dso_local noundef double @CompareDistmats(double noundef %distmat1_, double noundef %distmat2_) local_unnamed_addr #0 {
+; CHECK-LABEL: define dso_local noundef double @CompareDistmats(
+; CHECK-SAME: double noundef [[DISTMAT1_:%.*]], double noundef [[DISTMAT2_:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    [[SUB:%.*]] = fsub double [[DISTMAT1_]], [[DISTMAT2_]]
+; CHECK-NEXT:    [[TMP0:%.*]] = tail call double @llvm.fmuladd.f64(double [[SUB]], double [[SUB]], double 0.000000e+00)
+; CHECK-NEXT:    [[SQRT:%.*]] = call double @llvm.sqrt.f64(double [[TMP0]])
+; CHECK-NEXT:    ret double [[SQRT]]
+;
+entry:
+  %sub = fsub double %distmat1_, %distmat2_
+  %fmacall = tail call double @llvm.fmuladd.f64(double %sub, double %sub, double 0.000000e+00)
+  %call = tail call double @sqrt(double noundef %fmacall) #3
+  ret double %call
+}
+
+define dso_local noundef double @nonSquareCompareDistmats(double noundef %distmat1_, double noundef %distmat2_) local_unnamed_addr #0 {
+; CHECK-LABEL: define dso_local noundef double @nonSquareCompareDistmats(
+; CHECK-SAME: double noundef [[DISTMAT1_:%.*]], double noundef [[DISTMAT2_:%.*]]) local_unnamed_addr #[[ATTR0]] {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    [[SUB:%.*]] = fsub double [[DISTMAT1_]], [[DISTMAT2_]]
+; CHECK-NEXT:    [[ADD:%.*]] = fsub double [[DISTMAT1_]], [[DISTMAT2_]]
+; CHECK-NEXT:    [[FMACALL:%.*]] = tail call double @llvm.fmuladd.f64(double [[SUB]], double [[ADD]], double 0.000000e+00)
+; CHECK-NEXT:    [[CALL:%.*]] = tail call double @sqrt(double noundef [[FMACALL]]) #[[ATTR3:[0-9]+]]
+; CHECK-NEXT:    ret double [[CALL]]
+;
+entry:
+  %sub = fsub double %distmat1_, %distmat2_
+  %add = fsub double %distmat1_, %distmat2_
+  %fmacall = tail call double @llvm.fmuladd.f64(double %sub, double %add, double 0.000000e+00)
+  %call = tail call double @sqrt(double noundef %fmacall) #3
+  ret double %call
+}
+
+declare double @llvm.fmuladd.f64(double, double, double) #1
+
+declare double @sqrt(double noundef) local_unnamed_addr #2
+
+attributes #0 = { mustprogress nofree norecurse nounwind willreturn memory(errnomem: write) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="znver3" "target-features"="+adx,+aes,+avx,+avx2,+bmi,+bmi2,+clflushopt,+clwb,+clzero,+crc32,+cx16,+cx8,+f16c,+fma,+fsgsbase,+fxsr,+invpcid,+lzcnt,+mmx,+movbe,+mwaitx,+pclmul,+pku,+popcnt,+prfchw,+rdpid,+rdpru,+rdrnd,+rdseed,+sahf,+sha,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+sse4a,+ssse3,+vaes,+vpclmulqdq,+wbnoinvd,+x87,+xsave,+xsavec,+xsaveopt,+xsaves" }
----------------
arsenm wrote:

Remove all of these unnecessary attributes 

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


More information about the llvm-commits mailing list