[PATCH] D126775: [x86] fix miscompile from wrongly identified fneg

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 06:56:54 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3a503a4a9c1f: [x86] fix miscompile from wrongly identified fneg (authored by spatel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126775

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/X86/neg_fp.ll


Index: llvm/test/CodeGen/X86/neg_fp.ll
===================================================================
--- llvm/test/CodeGen/X86/neg_fp.ll
+++ llvm/test/CodeGen/X86/neg_fp.ll
@@ -82,11 +82,13 @@
   ret float %div5
 }
 
-; FIXME: PR55758 - this is not -(-X)
+; PR55758 - this is not -(-X)
 
 define <2 x i64> @fneg_mismatched_sizes(<4 x float> %x) {
 ; CHECK-LABEL: fneg_mismatched_sizes:
 ; CHECK:       # %bb.0:
+; CHECK-NEXT:    xorps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; CHECK-NEXT:    xorps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
 ; CHECK-NEXT:    retl
   %n = fneg <4 x float> %x
   %b = bitcast <4 x float> %n to <2 x i64>
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -50129,10 +50129,14 @@
         if (!UndefElts[I] && !EltBits[I].isSignMask())
           return SDValue();
 
-      return peekThroughBitcasts(Op0);
+      // Only allow bitcast from correctly-sized constant.
+      Op0 = peekThroughBitcasts(Op0);
+      if (Op0.getScalarValueSizeInBits() == ScalarSize)
+        return Op0;
     }
-  }
-  }
+    break;
+  } // case
+  } // switch
 
   return SDValue();
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126775.433380.patch
Type: text/x-patch
Size: 1240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220601/a45d7e0a/attachment-0001.bin>


More information about the llvm-commits mailing list