[PATCH] D142746: AMDGPU: Fold fneg into bitcast of build_vector

Pierre van Houtryve via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 8 03:00:43 PST 2023


Pierre-vh added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp:4144-4145
+      // fneg (f64 (bitcast (build_vector x, y))) ->
+      // f64 (bitcast (build_vector (bitcast i32:x to f32),
+      //                            (fneg (bitcast i32:y to f32)))
+
----------------
Wouldn't it make more sense to bitcast the fneg back to i32 to get 2xi32 -> f64? Would that change codegen?
2xf32 -> f64 looks wrong to me (even though it's correct in that context)


================
Comment at: llvm/test/CodeGen/AMDGPU/fneg-modifier-casting.ll:519
+; GFX11-NEXT:    v_and_b32_e32 v1, 1, v1
+; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_4)
 ; GFX11-NEXT:    v_cmp_eq_u32_e32 vcc_lo, 1, v0
----------------
There's a small regression here (1 extra instruction), is that addressed in a next patch?


================
Comment at: llvm/test/CodeGen/AMDGPU/fneg-modifier-casting.ll:919
+; GFX11-NEXT:    v_xor_b32_e32 v2, 0x80000000, v1
+; GFX11-NEXT:    v_cndmask_b32_e32 v1, v1, v2, vcc_lo
 ; GFX11-NEXT:    s_setpc_b64 s[30:31]
----------------
ditto


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142746/new/

https://reviews.llvm.org/D142746



More information about the llvm-commits mailing list