[llvm] r312995 - [X86] Add an extra instruction to TruncAssertSext.ll to prevent the 'or' from being narrowed so that the movl is really required to avoid a miscompile.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 11 20:50:44 PDT 2017


Author: ctopper
Date: Mon Sep 11 20:50:44 2017
New Revision: 312995

URL: http://llvm.org/viewvc/llvm-project?rev=312995&view=rev
Log:
[X86] Add an extra instruction to TruncAssertSext.ll to prevent the 'or' from being narrowed so that the movl is really required to avoid a miscompile.

If we allow the OR to be narrowed then the upper bits really are zero and we can't tell if the zeroing movl was removed on purpose.

While here regenerate the test with update_llc_test_checks.py

Modified:
    llvm/trunk/test/CodeGen/X86/TruncAssertSext.ll

Modified: llvm/trunk/test/CodeGen/X86/TruncAssertSext.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/TruncAssertSext.ll?rev=312995&r1=312994&r2=312995&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/TruncAssertSext.ll (original)
+++ llvm/trunk/test/CodeGen/X86/TruncAssertSext.ll Mon Sep 11 20:50:44 2017
@@ -1,16 +1,20 @@
-; RUN: llc < %s -O2 -mtriple=x86_64-- | FileCheck %s
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -O2 -mtriple=x86_64-unknown-unknown | FileCheck %s
 ; Checks that a zeroing mov is inserted for the trunc/zext pair even when
 ; the source of the zext is an AssertSext node
 ; PR20494
 
 define i64 @main(i64 %a) {
-; CHECK-LABEL: main
-; CHECK: movl %e{{..}}, %eax
-; CHECK: ret
+; CHECK-LABEL: main:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    orq $-2, %rdi
+; CHECK-NEXT:    movl %edi, %eax
+; CHECK-NEXT:    retq
   %or = or i64 %a, -2
   %trunc = trunc i64 %or to i32
   br label %l
 l:
   %ext = zext i32 %trunc to i64
+  trunc i64 %or to i32 ; to keep the or from being narrowed
   ret i64 %ext
 }




More information about the llvm-commits mailing list