[llvm] [InstCombine] Treat `asin`, `asinh`, `atan`, `atan2` and `cbrt` as odd-functions (PR #227336)

Eric Ross via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 10:57:28 PDT 2026


================
@@ -20,6 +25,73 @@ define double @test_erf(double %x) {
   ret double %neg_res
 }
 
+; Check odd parity: -asin(-x) == asin(x)
+define double @test_asin(double %x) {
+; CHECK-LABEL: define double @test_asin(
+; CHECK-SAME: double [[X:%.*]]) {
+; CHECK-NEXT:    [[NEG_RES:%.*]] = tail call reassoc double @asin(double [[X]])
+; CHECK-NEXT:    ret double [[NEG_RES]]
+;
+  %neg_x = fneg double %x
+  %res = tail call reassoc double @asin(double %neg_x)
+  %neg_res = fneg double %res
+  ret double %neg_res
+}
+
+; Check odd parity: -asinh(-x) == asinh(x)
+define double @test_asinh(double %x) {
+; CHECK-LABEL: define double @test_asinh(
+; CHECK-SAME: double [[X:%.*]]) {
+; CHECK-NEXT:    [[NEG_RES:%.*]] = tail call reassoc double @asinh(double [[X]])
+; CHECK-NEXT:    ret double [[NEG_RES]]
+;
+  %neg_x = fneg double %x
+  %res = tail call reassoc double @asinh(double %neg_x)
+  %neg_res = fneg double %res
+  ret double %neg_res
+}
+
+; Check odd parity: -atan(-x) == atan(x)
+define double @test_atan(double %x) {
+; CHECK-LABEL: define double @test_atan(
+; CHECK-SAME: double [[X:%.*]]) {
+; CHECK-NEXT:    [[NEG_RES:%.*]] = tail call reassoc double @atan(double [[X]])
+; CHECK-NEXT:    ret double [[NEG_RES]]
+;
+  %neg_x = fneg double %x
+  %res = tail call reassoc double @atan(double %neg_x)
+  %neg_res = fneg double %res
+  ret double %neg_res
+}
+
+; Check odd parity: -atan2(-x) == atan2(x)
----------------
ZERICO2005 wrote:

Should be `-atan2(-y, x) == atan2(y, x)`.


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


More information about the llvm-commits mailing list