--- /dev/null
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -instcombine -S < %s | FileCheck %s
+
+declare double @llvm.powi.f64.i32(double, i32)
+declare double @llvm.fabs.f64(double)
+declare double @llvm.copysign.f64(double, double)
+
+define double @powi_fneg_even_int(double %x) {
+; CHECK-LABEL: @powi_fneg_even_int(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[FNEG:%.*]] = fneg double [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = tail call double @llvm.powi.f64.i32(double [[FNEG]], i32 4)
+; CHECK-NEXT: ret double [[R]]
+;
+entry:
+ %fneg = fneg double %x
+ %r = tail call double @llvm.powi.f64.i32(double %fneg, i32 4)
+ ret double %r
+}
+
+define double @powi_fabs_even_int(double %x) {
+; CHECK-LABEL: @powi_fabs_even_int(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[F:%.*]] = tail call double @llvm.fabs.f64(double [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = tail call double @llvm.powi.f64.i32(double [[F]], i32 4)
+; CHECK-NEXT: ret double [[R]]
+;
+entry:
+ %f = tail call double @llvm.fabs.f64(double %x)
+ %r = tail call double @llvm.powi.f64.i32(double %f, i32 4)
+ ret double %r
+}
+
+define double @powi_copysign_even_int(double %x, double %y) {
+; CHECK-LABEL: @powi_copysign_even_int(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CS:%.*]] = tail call double @llvm.copysign.f64(double [[X:%.*]], double [[Y:%.*]])
+; CHECK-NEXT: [[R:%.*]] = tail call double @llvm.powi.f64.i32(double [[CS]], i32 4)
+; CHECK-NEXT: ret double [[R]]
+;
+entry:
+ %cs = tail call double @llvm.copysign.f64(double %x, double %y)
+ %r = tail call double @llvm.powi.f64.i32(double %cs, i32 4)
+ ret double %r
+}
+
+define double @powi_fneg_odd_int(double %x) {
+; CHECK-LABEL: @powi_fneg_odd_int(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[FNEG:%.*]] = fneg double [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = tail call double @llvm.powi.f64.i32(double [[FNEG]], i32 5)
+; CHECK-NEXT: ret double [[R]]
+;
+entry:
+ %fneg = fneg double %x
+ %r = tail call double @llvm.powi.f64.i32(double %fneg, i32 5)
+ ret double %r
+}
+
+define double @powi_fabs_odd_int(double %x) {
+; CHECK-LABEL: @powi_fabs_odd_int(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[F:%.*]] = tail call double @llvm.fabs.f64(double [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = tail call double @llvm.powi.f64.i32(double [[F]], i32 5)
+; CHECK-NEXT: ret double [[R]]
+;
+entry:
+ %f = tail call double @llvm.fabs.f64(double %x)
+ %r = tail call double @llvm.powi.f64.i32(double %f, i32 5)
+ ret double %r
+}
+
+define double @powi_copysign_odd_int(double %x, double %y) {
+; CHECK-LABEL: @powi_copysign_odd_int(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CS:%.*]] = tail call double @llvm.copysign.f64(double [[X:%.*]], double [[Y:%.*]])
+; CHECK-NEXT: [[R:%.*]] = tail call double @llvm.powi.f64.i32(double [[CS]], i32 5)
+; CHECK-NEXT: ret double [[R]]
+;
+entry:
+ %cs = tail call double @llvm.copysign.f64(double %x, double %y)
+ %r = tail call double @llvm.powi.f64.i32(double %cs, i32 5)
+ ret double %r
+}