[PATCH] D125671: [InstCombine] Allow undef vectors when foldSelectToCopysign

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 17 13:19:32 PDT 2022


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:2306-2307
   // not care about its sign.
-  Value *MagArg = TC->isNegative() ? FVal : TVal;
+  Value *MagArg = TC->isNegative() ? ConstantFP::get(SelType, *FC)
+                                   : ConstantFP::get(SelType, *TC);
   Function *F = Intrinsic::getDeclaration(Sel.getModule(), Intrinsic::copysign,
----------------
This might be more efficient and easier to read:
   Value *MagArg = ConstantFP::get(SelType, abs(*TC));



================
Comment at: llvm/test/Transforms/InstCombine/select.ll:1711
   %i = bitcast <2 x float> %x to <2 x i32>
   %isneg = icmp ugt <2 x i32> %i, <i32 2147483647, i32 2147483647>
   %r = select arcp nnan <2 x i1> %isneg, <2 x float> <float 42.0, float 42.0>, <2 x float> <float undef, float -42.0>
----------------
Test coverage would be better if you vary the predicate (for example `ule`). Also, swap the positive and negative constants on the next test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125671



More information about the llvm-commits mailing list