[PATCH] D47686: [InstCombine] refine UB-handling in shuffle-binop transform

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 3 07:50:31 PDT 2018


lebedev.ri added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:1427-1428
+      BinaryOperator::BinaryOps Opcode = Inst.getOpcode();
+      if (Opcode == Instruction::UDiv || Opcode == Instruction::URem ||
+          Opcode == Instruction::SDiv || Opcode == Instruction::SRem)
+        for (unsigned i = 0; i < VWidth; ++i)
----------------
No special-handling for `fdiv`/`frem`?


================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:1431
+          if (isa<UndefValue>(NewVecC[i]))
+            NewVecC[i] = ConstantInt::get(Inst.getType()->getScalarType(), 1);
 
----------------
We want `int(1)` even for `float`s?


================
Comment at: test/Transforms/InstCombine/vec_shuffle.ll:855
 ; CHECK-LABEL: @fsub_splat_constant1(
-; CHECK-NEXT:    [[TMP1:%.*]] = fadd <2 x float> [[X:%.*]], <float -4.200000e+01, float -4.200000e+01>
+; CHECK-NEXT:    [[TMP1:%.*]] = fadd <2 x float> [[X:%.*]], <float -4.200000e+01, float 0x7FF8000000000000>
 ; CHECK-NEXT:    [[R:%.*]] = shufflevector <2 x float> [[TMP1]], <2 x float> undef, <2 x i32> zeroinitializer
----------------
This looks like a float `NAN`?



https://reviews.llvm.org/D47686





More information about the llvm-commits mailing list