[llvm] [AMDGPU] Skip fold_pow constant-exponent shortcuts for powr on possibly-negative base (PR #200579)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 8 09:20:30 PDT 2026


================
@@ -171,57 +173,32 @@ define float @test_powr_afn_f32__half(float %x) #0 {
 ; CHECK-LABEL: define float @test_powr_afn_f32__half(
 ; CHECK-SAME: float [[X:%.*]]) #[[ATTR0]] {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
-; CHECK-NEXT:    [[__POW2SQRT:%.*]] = call nsz afn float @_Z4sqrtf(float [[X]])
+; CHECK-NEXT:    [[__POW2SQRT:%.*]] = tail call afn float @_Z11__powr_fastff(float [[X]], float 5.000000e-01)
 ; CHECK-NEXT:    ret float [[__POW2SQRT]]
 ;
 entry:
-  %call = tail call nsz afn float @_Z4powrff(float %x, float 0.5)
+  %call = tail call afn float @_Z4powrff(float %x, float 0.5)
   ret float %call
 }
 
 define float @test_powr_afn_f32__neghalf(float %x) #0 {
 ; CHECK-LABEL: define float @test_powr_afn_f32__neghalf(
 ; CHECK-SAME: float [[X:%.*]]) #[[ATTR0]] {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
-; CHECK-NEXT:    [[__POW2RSQRT:%.*]] = call nsz afn float @_Z5rsqrtf(float [[X]])
+; CHECK-NEXT:    [[__POW2RSQRT:%.*]] = tail call afn float @_Z11__powr_fastff(float [[X]], float -5.000000e-01)
 ; CHECK-NEXT:    ret float [[__POW2RSQRT]]
 ;
-entry:
-  %call = tail call nsz afn float @_Z4powrff(float %x, float -0.5)
-  ret float %call
-}
-
-; powr(x, -0.5) with afn only must NOT fold to rsqrt: nsz is required.
-define float @test_powr_afn_only_f32__neghalf(float %x) #0 {
-; CHECK-LABEL: define float @test_powr_afn_only_f32__neghalf(
-; CHECK-SAME: float [[X:%.*]]) #[[ATTR0]] {
-; CHECK-NEXT:  [[ENTRY:.*:]]
-; CHECK-NEXT:    [[CALL:%.*]] = tail call afn float @_Z11__powr_fastff(float [[X]], float -5.000000e-01)
-; CHECK-NEXT:    ret float [[CALL]]
-;
 entry:
   %call = tail call afn float @_Z4powrff(float %x, float -0.5)
   ret float %call
 }
 
-; powr(x, 0.5) with afn only must NOT fold to sqrt: nsz is required.
-define float @test_powr_afn_only_f32__half(float %x) #0 {
----------------
arsenm wrote:

Shouldn't lose the test, should add the nnan or whatever to ensure the purpose is preserved 

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


More information about the llvm-commits mailing list